-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
show basket details script & token supply
- Loading branch information
Showing
6 changed files
with
206 additions
and
45 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as fcl from "@onflow/fcl"; | ||
|
||
|
||
export type FTDetailType = Record<string, { | ||
tokenIdentifier: string | ||
tokenName: string | ||
tokenContratName: string | ||
tokenstring: string | ||
tokenSymbol: string | ||
vaultPath: string | ||
receiverPath: string | ||
balancePath: string | ||
}> | ||
|
||
export const getFTDetails = async () => { | ||
const code = ` | ||
import BasketTokenV2 from 0xf88c87364f7f298e | ||
pub fun main(): {String: BasketTokenV2.TokenInfo} { | ||
let tokens = BasketTokenV2.getTokens() | ||
return tokens | ||
} | ||
` | ||
const data = await fcl.query({ | ||
cadence: code | ||
}) | ||
console.log(data) | ||
return data | ||
} |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as fcl from "@onflow/fcl"; | ||
|
||
export const GetUnderlyingTokens = (contractName: string) => { | ||
return ` | ||
import ${contractName} from 0xf88c87364f7f298e | ||
pub struct UnderLyingTokenData { | ||
pub let tokenIdentifier: String | ||
pub let amount: UFix64 | ||
init(tokenIdentifier: String, amount: UFix64) { | ||
self.tokenIdentifier = tokenIdentifier | ||
self.amount = amount | ||
} | ||
} | ||
pub fun main(): [UnderLyingTokenData] { | ||
let tokens = ${contractName}.getUnderlyingTokens() | ||
let amounts = ${contractName}.getUnderlyingTokensAmount() | ||
let data: [UnderLyingTokenData] = [] | ||
for i, _ in tokens { | ||
let d = UnderLyingTokenData(tokenIdentifier :tokens[i], amount: amounts[i]) | ||
data.append(d) | ||
} | ||
return data | ||
} | ||
` | ||
} | ||
|
||
export const getUnderlyingTokensData = async (contractName: string) => { | ||
const data = await fcl.query({ | ||
cadence: GetUnderlyingTokens(contractName) | ||
}) | ||
|
||
return data | ||
} |
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as fcl from "@onflow/fcl"; | ||
|
||
export const getTokenTotalSupply = async (contractName: string, adminAddress: string) => { | ||
const code = ` | ||
import ${contractName} from ${adminAddress} | ||
pub fun main(): UFix64 { | ||
return ${contractName}.totalSupply | ||
} | ||
` | ||
const data = await fcl.query({ | ||
cadence: code | ||
}) | ||
|
||
return data | ||
} |
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