-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@mintbase-js/rpc: add rpcUrl mandatory param (#521)
Co-authored-by: Benjamin Smith <bh2smith@users.noreply.github.com> Co-authored-by: mintbaseteam <eng@mintbase.io> Co-authored-by: Till <31419678+tifrel@users.noreply.github.com>
- Loading branch information
1 parent
c514a1e
commit f7538bb
Showing
48 changed files
with
2,845 additions
and
5,732 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
"packages": [ | ||
"packages/*" | ||
] | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,3 @@ export const tokenOwnersByMetadataIdMock = { | |
}, | ||
}, | ||
}; | ||
|
2 changes: 1 addition & 1 deletion
2
packages/data/src/api/userMintedTokens/userMintedTokens.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
import BN from 'bn.js'; | ||
import { RPC_OPTIONS, requestFromNearRpc } from '../util'; | ||
import { Network } from '@mintbase-js/sdk'; | ||
import { callNearRpc, } from '../util'; | ||
import { AccountParams } from '../types'; | ||
|
||
export const getBalance = async (accountId: string, network?: Network, rpc?: RPC_OPTIONS): Promise<BN> => { | ||
const res = await requestFromNearRpc({ | ||
jsonrpc: '2.0', | ||
id: 'dontcare', | ||
method: 'query', | ||
export const getBalance = async ({ accountId, rpcUrl }: AccountParams): Promise<BN> => { | ||
|
||
const res = await callNearRpc({ | ||
params: { | ||
request_type: 'view_account', | ||
finality: 'final', | ||
account_id: accountId, | ||
}, | ||
}, network, rpc); | ||
request_type: 'view_account', | ||
finality: 'final', | ||
account_id: accountId, | ||
}, | ||
method:'query', | ||
rpcUrl | ||
}) | ||
|
||
const balanceString = res?.result?.amount as string; | ||
if (!balanceString) { | ||
throw new Error(`Malformed response: ${JSON.stringify(res)}`); | ||
} | ||
return new BN(balanceString); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,11 @@ | ||
import { Network } from '@mintbase-js/sdk'; | ||
import { RPC_OPTIONS, callViewMethod } from '../util'; | ||
import { FTParams } from '../types'; | ||
import { callViewMethod } from '../util'; | ||
|
||
interface FTBalanceProps { | ||
contractId: string; | ||
accountId: string; | ||
network?: Network; | ||
rpc?: RPC_OPTIONS; | ||
} | ||
|
||
export const ftBalance = async ({ contractId, accountId, network, rpc }: FTBalanceProps): Promise<string> => { | ||
export const ftBalance = async ({ contractId, accountId, rpcUrl }: FTParams): Promise<string> => { | ||
return callViewMethod<string>({ | ||
contractId, | ||
method: 'ft_balance_of', | ||
args: { account_id: accountId }, | ||
network: network, | ||
rpc, | ||
rpcUrl, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
import { Network } from '@mintbase-js/sdk'; | ||
import { RPC_OPTIONS, requestFromNearRpc } from '../util'; | ||
import { callNearRpc } from '../util'; | ||
|
||
export const getBlockHash = async (network?: Network, rpc?: RPC_OPTIONS): Promise<string> => { | ||
const res = await requestFromNearRpc({ | ||
jsonrpc: '2.0', | ||
id: 'dontcare', | ||
export const getBlockHash = async (rpcUrl: string): Promise<string> => { | ||
const res = await callNearRpc({ | ||
method: 'status', | ||
params: [], | ||
}, network, rpc); | ||
rpcUrl | ||
}, ); | ||
|
||
const blockHash = (res?.result?.sync_info as {latest_block_hash: string})?.latest_block_hash; | ||
|
||
if (!blockHash) { | ||
throw new Error(`Malformed response: ${JSON.stringify(res)}`); | ||
} | ||
|
||
return blockHash; | ||
}; |
Oops, something went wrong.