Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/networks/bitcoin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"url": "https://github.com/MultipleChain/js/issues"
},
"dependencies": {
"@multiplechain/types": "^0.1.66",
"@multiplechain/types": "^0.1.68",
"@multiplechain/utils": "^0.1.21",
"axios": "^1.6.8",
"bitcore-lib": "^10.0.28",
Expand Down
8 changes: 4 additions & 4 deletions packages/networks/bitcoin/pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion packages/networks/boilerplate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"url": "https://github.com/MultipleChain/js/issues"
},
"dependencies": {
"@multiplechain/types": "^0.1.66",
"@multiplechain/types": "^0.1.67",
"@multiplechain/utils": "^0.1.21"
}
}
8 changes: 4 additions & 4 deletions packages/networks/boilerplate/pnpm-lock.yaml

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

18 changes: 18 additions & 0 deletions packages/networks/boilerplate/src/assets/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export class Contract implements ContractInterface {
*/
address: ContractAddress

/**
* Cached static methods
*/
cachedMethods: Record<string, unknown> = {}

/**
* Blockchain network provider
*/
Expand Down Expand Up @@ -37,6 +42,19 @@ export class Contract implements ContractInterface {
return {}
}

/**
* @param {string} method Method name
* @param {unknown[]} args Method parameters
* @returns {Promise<unknown>} Method result
*/
async callMethodWithCache(method: string, ...args: unknown[]): Promise<unknown> {
if (this.cachedMethods[method] !== undefined) {
return this.cachedMethods[method]
}

return (this.cachedMethods[method] = await this.callMethod(method, ...args))
}

/**
* @param {string} method Method name
* @param {unknown[]} args Sender wallet address
Expand Down
4 changes: 2 additions & 2 deletions packages/networks/evm-chains/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiplechain/evm-chains",
"version": "0.4.4",
"version": "0.4.5",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.es.js",
Expand Down Expand Up @@ -75,7 +75,7 @@
"url": "https://github.com/MultipleChain/js/issues"
},
"dependencies": {
"@multiplechain/types": "^0.1.66",
"@multiplechain/types": "^0.1.68",
"@multiplechain/utils": "^0.1.21",
"@wagmi/chains": "^1.8.0",
"@walletconnect/ethereum-provider": "^2.12.2",
Expand Down
8 changes: 4 additions & 4 deletions packages/networks/evm-chains/pnpm-lock.yaml

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

18 changes: 18 additions & 0 deletions packages/networks/evm-chains/src/assets/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class Contract implements ContractInterface {
*/
address: ContractAddress

/**
* Cached static methods
*/
cachedMethods: Record<string, unknown> = {}

/**
* Contract ABI
*/
Expand Down Expand Up @@ -59,6 +64,19 @@ export class Contract implements ContractInterface {
return this.ethersContract[method](...args) // eslint-disable-line
}

/**
* @param {string} method Method name
* @param {unknown[]} args Method parameters
* @returns {Promise<unknown>} Method result
*/
async callMethodWithCache(method: string, ...args: unknown[]): Promise<unknown> {
if (this.cachedMethods[method] !== undefined) {
return this.cachedMethods[method]
}

return (this.cachedMethods[method] = await this.callMethod(method, ...args))
}

/**
* @param {string} method Method name
* @param {unknown[]} args Sender wallet address
Expand Down
6 changes: 3 additions & 3 deletions packages/networks/evm-chains/src/assets/NFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export class NFT extends Contract implements NftInterface<TransactionSigner> {
* @returns {Promise<string>} NFT name
*/
async getName(): Promise<string> {
return (await this.callMethod('name')) as string
return (await this.callMethodWithCache('name')) as string
}

/**
* @returns {Promise<string>} NFT symbol
*/
async getSymbol(): Promise<string> {
return (await this.callMethod('symbol')) as string
return (await this.callMethodWithCache('symbol')) as string
}

/**
Expand All @@ -56,7 +56,7 @@ export class NFT extends Contract implements NftInterface<TransactionSigner> {
* @returns {Promise<string>} URI of the NFT
*/
async getTokenURI(nftId: NftId): Promise<string> {
return (await this.callMethod('tokenURI', nftId)) as string
return (await this.callMethodWithCache('tokenURI', nftId)) as string
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/networks/evm-chains/src/assets/Token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ export class Token extends Contract implements TokenInterface<TransactionSigner>
* @returns {Promise<string>} Token name
*/
async getName(): Promise<string> {
return (await this.callMethod('name')) as string
return (await this.callMethodWithCache('name')) as string
}

/**
* @returns {Promise<string>} Token symbol
*/
async getSymbol(): Promise<string> {
return (await this.callMethod('symbol')) as string
return (await this.callMethodWithCache('symbol')) as string
}

/**
* @returns {Promise<number>} Decimal value of the token
*/
async getDecimals(): Promise<number> {
return Number(await this.callMethod('decimals'))
return Number(await this.callMethodWithCache('decimals'))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/networks/solana/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"dependencies": {
"@metaplex-foundation/js": "^0.20.1",
"@multiplechain/solana-walletconnect": "^0.1.1",
"@multiplechain/types": "^0.1.66",
"@multiplechain/types": "^0.1.68",
"@multiplechain/utils": "^0.1.21",
"@solana/spl-token": "^0.4.6",
"@solana/spl-token-metadata": "^0.1.4",
Expand Down
8 changes: 4 additions & 4 deletions packages/networks/solana/pnpm-lock.yaml

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

18 changes: 18 additions & 0 deletions packages/networks/solana/src/assets/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export class Contract implements ContractInterface {
*/
address: ContractAddress

/**
* Cached static methods
*/
cachedMethods: Record<string, unknown> = {}

/**
* Contract public key
*/
Expand Down Expand Up @@ -44,6 +49,19 @@ export class Contract implements ContractInterface {
throw new Error('Method not implemented.')
}

/**
* @param {string} method Method name
* @param {unknown[]} args Method parameters
* @returns {Promise<unknown>} Method result
*/
async callMethodWithCache(method: string, ...args: unknown[]): Promise<unknown> {
if (this.cachedMethods[method] !== undefined) {
return this.cachedMethods[method]
}

return (this.cachedMethods[method] = await this.callMethod(method, ...args))
}

/**
* @param {string} _method Method name
* @param {unknown[]} _args Sender wallet address
Expand Down
4 changes: 2 additions & 2 deletions packages/networks/tron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@multiplechain/tron",
"version": "0.4.4",
"version": "0.4.5",
"type": "module",
"main": "dist/index.cjs",
"module": "dist/index.es.js",
Expand Down Expand Up @@ -74,7 +74,7 @@
"dependencies": {
"@beycandeveloper/tron-tx-decoder": "^2.0.5",
"@multiplechain/tron-walletconnect": "^0.1.0",
"@multiplechain/types": "^0.1.66",
"@multiplechain/types": "^0.1.68",
"@multiplechain/utils": "^0.1.21",
"@noble/secp256k1": "^1.7.1",
"@tronweb3/tronwallet-adapter-bitkeep": "^1.1.1",
Expand Down
8 changes: 4 additions & 4 deletions packages/networks/tron/pnpm-lock.yaml

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

18 changes: 18 additions & 0 deletions packages/networks/tron/src/assets/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class Contract implements ContractInterface {
*/
address: ContractAddress

/**
* Cached static methods
*/
cachedMethods: Record<string, unknown> = {}

/**
* Blockchain network provider
*/
Expand Down Expand Up @@ -108,6 +113,19 @@ export class Contract implements ContractInterface {
return this.tronContract[method](...args).call() // eslint-disable-line
}

/**
* @param {string} method Method name
* @param {unknown[]} args Method parameters
* @returns {Promise<unknown>} Method result
*/
async callMethodWithCache(method: string, ...args: unknown[]): Promise<unknown> {
if (this.cachedMethods[method] !== undefined) {
return this.cachedMethods[method]
}

return (this.cachedMethods[method] = await this.callMethod(method, ...args))
}

/**
* @param {string} _method Method name
* @param {unknown[]} _args Sender wallet address
Expand Down
6 changes: 3 additions & 3 deletions packages/networks/tron/src/assets/NFT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ export class NFT extends Contract implements NftInterface<TransactionSigner> {
* @returns {Promise<string>} NFT name
*/
async getName(): Promise<string> {
return (await this.callMethod('name')) as string
return (await this.callMethodWithCache('name')) as string
}

/**
* @returns {Promise<string>} NFT symbol
*/
async getSymbol(): Promise<string> {
return (await this.callMethod('symbol')) as string
return (await this.callMethodWithCache('symbol')) as string
}

/**
Expand All @@ -55,7 +55,7 @@ export class NFT extends Contract implements NftInterface<TransactionSigner> {
* @returns {Promise<string>} URI of the NFT
*/
async getTokenURI(nftId: NftId): Promise<string> {
return (await this.callMethod('tokenURI', nftId)) as string
return (await this.callMethodWithCache('tokenURI', nftId)) as string
}

/**
Expand Down
Loading