Skip to content

Commit

Permalink
Feature/pro 610 adding field for ipfs image gateway (#177)
Browse files Browse the repository at this point in the history
* Updated transactions.service.ts and nft.ts

- Added ipfsGateway field to the gql query for getNftList and for Nft class

* 1.37.1
  • Loading branch information
cryptonoyaiba authored Oct 4, 2022
1 parent 3c5e224 commit 08549a6
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 61 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "etherspot",
"version": "1.37.0",
"version": "1.37.1",
"description": "Etherspot SDK",
"keywords": [
"ether",
Expand Down
2 changes: 2 additions & 0 deletions src/sdk/transactions/classes/nft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ export class Nft extends BaseClass<Nft> {
amount: number;

image: string;

ipfsGateway: string;
}
145 changes: 87 additions & 58 deletions src/sdk/transactions/transactions.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { gql } from '@apollo/client/core';
import { BigNumber } from 'ethers';
import { Service } from '../common';
import { KnownContract, KnownContracts, NftList, StreamList, StreamTransactionPayload, Transaction, Transactions } from './classes';
import {
KnownContract,
KnownContracts,
NftList,
StreamList,
StreamTransactionPayload,
Transaction,
Transactions,
} from './classes';

export class TransactionsService extends Service {
async getTransaction(hash: string): Promise<Transaction> {
Expand Down Expand Up @@ -124,6 +132,7 @@ export class TransactionsService extends Service {
name
amount
image
ipfsGateway
}
}
}
Expand All @@ -148,17 +157,31 @@ export class TransactionsService extends Service {
amount: BigNumber,
tokenAddress: string,
userData: string,
skipBalanceCheck: boolean
skipBalanceCheck: boolean,
): Promise<StreamTransactionPayload> {
const { apiService } = this.services;

const { result } = await apiService.query<{
result: StreamTransactionPayload;
}>(
gql`
query($account: String!, $receiver: String!, $amount: BigNumber!, $tokenAddress: String!, $chainId: Int!, $userData: String, $skipBalanceCheck: Boolean) {
query(
$account: String!
$receiver: String!
$amount: BigNumber!
$tokenAddress: String!
$chainId: Int!
$userData: String
$skipBalanceCheck: Boolean
) {
result: streamTransactionPayload(
account: $account, receiver: $receiver, amount: $amount, tokenAddress: $tokenAddress, chainId: $chainId, userData: $userData, skipBalanceCheck: $skipBalanceCheck
account: $account
receiver: $receiver
amount: $amount
tokenAddress: $tokenAddress
chainId: $chainId
userData: $userData
skipBalanceCheck: $skipBalanceCheck
) {
data
to
Expand Down Expand Up @@ -197,9 +220,23 @@ export class TransactionsService extends Service {
result: StreamTransactionPayload;
}>(
gql`
query($account: String!, $receiver: String!, $amount: BigNumber!, $tokenAddress: String!, $chainId: Int!, $userData: String, $skipBalanceCheck: Boolean) {
query(
$account: String!
$receiver: String!
$amount: BigNumber!
$tokenAddress: String!
$chainId: Int!
$userData: String
$skipBalanceCheck: Boolean
) {
result: modifyTransactionPayload(
account: $account, receiver: $receiver, amount: $amount, tokenAddress: $tokenAddress, chainId: $chainId, userData: $userData, skipBalanceCheck: $skipBalanceCheck
account: $account
receiver: $receiver
amount: $amount
tokenAddress: $tokenAddress
chainId: $chainId
userData: $userData
skipBalanceCheck: $skipBalanceCheck
) {
data
to
Expand Down Expand Up @@ -237,7 +274,13 @@ export class TransactionsService extends Service {
}>(
gql`
query($account: String!, $receiver: String!, $tokenAddress: String!, $chainId: Int!, $userData: String) {
result: deleteTransactionPayload(account: $account, receiver: $receiver, tokenAddress: $tokenAddress, chainId: $chainId, userData: $userData) {
result: deleteTransactionPayload(
account: $account
receiver: $receiver
tokenAddress: $tokenAddress
chainId: $chainId
userData: $userData
) {
data
to
error
Expand All @@ -259,9 +302,7 @@ export class TransactionsService extends Service {
return result;
}

async getStreamList(
account: string,
): Promise<StreamList> {
async getStreamList(account: string): Promise<StreamList> {
const { apiService } = this.services;

const { result } = await apiService.query<{
Expand Down Expand Up @@ -326,7 +367,7 @@ export class TransactionsService extends Service {
underlyingToken: string,
underlyingDecimals: number,
name: string,
symbol: string
symbol: string,
): Promise<StreamTransactionPayload> {
const { apiService } = this.services;

Expand All @@ -336,14 +377,14 @@ export class TransactionsService extends Service {
gql`
query($chainId: Int!, $underlyingToken: String!, $underlyingDecimals: Int, $name: String, $symbol: String) {
result: createSuperERC20WrapperTransactionPayload(
chainId: $chainId,
underlyingToken: $underlyingToken,
underlyingDecimals: $underlyingDecimals,
name: $name,
chainId: $chainId
underlyingToken: $underlyingToken
underlyingDecimals: $underlyingDecimals
name: $name
symbol: $symbol
) {
error,
data,
error
data
to
}
}
Expand All @@ -369,26 +410,20 @@ export class TransactionsService extends Service {
chainId: number,
underlyingDecimals: number,
name: string,
symbol: string
symbol: string,
): Promise<string> {
const { apiService } = this.services;

const { result } = await apiService.query<{
result: string;
}>(
gql`
query(
$chainId: Int!,
$underlyingToken: String!,
$underlyingDecimals: Int,
$name: String,
$symbol: String
) {
query($chainId: Int!, $underlyingToken: String!, $underlyingDecimals: Int, $name: String, $symbol: String) {
result: findSuperERC20WrapperOnChain(
chainId: $chainId,
underlyingToken: $underlyingToken,
underlyingDecimals: $underlyingDecimals,
name: $name,
chainId: $chainId
underlyingToken: $underlyingToken
underlyingDecimals: $underlyingDecimals
name: $name
symbol: $symbol
)
}
Expand All @@ -406,29 +441,23 @@ export class TransactionsService extends Service {
return result;
}

async registerERC20WrapperToken(
wrapperAddress: string,
chainId?: number
): Promise<KnownContract | null> {
async registerERC20WrapperToken(wrapperAddress: string, chainId?: number): Promise<KnownContract | null> {
const { apiService } = this.services;

const { result } = await apiService.query<{
result: KnownContract;
}>(
gql`
query($chainId: Int!, $wrapperAddress: String!) {
result: registerERC20WrapperToken(
chainId: $chainId,
wrapperAddress: $wrapperAddress,
) {
id,
chainId,
contractName,
contractSymbol,
contractAddress,
tokenType,
nftVersion,
decimals,
result: registerERC20WrapperToken(chainId: $chainId, wrapperAddress: $wrapperAddress) {
id
chainId
contractName
contractSymbol
contractAddress
tokenType
nftVersion
decimals
underlyingToken
}
}
Expand All @@ -439,8 +468,8 @@ export class TransactionsService extends Service {
wrapperAddress,
},
models: {
result: KnownContract
}
result: KnownContract,
},
},
);

Expand All @@ -456,25 +485,25 @@ export class TransactionsService extends Service {
gql`
query {
result: getRegisteredERC20WrapperTokens {
chains,
chains
items {
id,
chainId,
contractName,
contractSymbol,
contractAddress,
tokenType,
nftVersion,
decimals,
id
chainId
contractName
contractSymbol
contractAddress
tokenType
nftVersion
decimals
underlyingToken
}
}
}
`,
{
models: {
result: KnownContracts
}
result: KnownContracts,
},
},
);

Expand Down

0 comments on commit 08549a6

Please sign in to comment.