This file contains hidden or 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
import { KeyringPair } from '@polkadot/keyring/types' | |
import { | |
batterystation, | |
create, | |
CreateMarketParams, | |
RpcContext, | |
Sdk, | |
swapFeeFromFloat, | |
ZTG, | |
} from '@zeitgeistpm/sdk' |
This file contains hidden or 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
import { KeyringPair } from '@polkadot/keyring/types' | |
import { | |
batterystation, | |
create, | |
CreateMarketParams, | |
RpcContext, | |
Sdk, | |
swapFeeFromFloat, | |
ZTG, | |
} from '@zeitgeistpm/sdk' |
This file contains hidden or 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
import seedrandom from "seedrandom"; | |
/** | |
* Pseudo-random number generator that returns a number between min and max deterministically based on a seed. | |
* | |
* @param seed string | |
* @param min min range value | |
* @param max max range value | |
* @returns number | |
*/ |
This file contains hidden or 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
import { create, createStorage, CreateMarketWithPoolParams } from '@zeitgeistpm/sdk' | |
import { IPFS } from '@zeitgeistpm/web3.storage' | |
type CustomMarketMetadata = { description: string } | |
const storage = createStorage<CustomMarketMetadata>( | |
IPFS.storage({ | |
node: { url: 'http://ipfs.zeitgeist.pm:5001', pin: false }, | |
}), | |
) |
This file contains hidden or 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
import { useEffect, useState } from 'react' | |
import { batterystation, builder, Context, Sdk } from '@zeitgeistpm/sdk' | |
import { MarketList } from './components/MarketList' | |
const App: React.FC = () => { | |
const [sdk, setSdk] = useState<Partial<Sdk<Context>>>({}) | |
useEffect(() => { | |
/** | |
* Sdk can be either RpcSdk, IndexedSdk or Both. |
This file contains hidden or 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
import { Context, isIndexedData, isRpcData, isRpcSdk, Sdk } from '@zeitgeistpm/sdk' | |
import { RpcPoolPrices } from '@zeitgeistpm/sdk/dist/model/assets' | |
import { Pool } from '@zeitgeistpm/sdk/dist/model/swaps/pool' | |
import { Market } from '@zeitgeistpm/sdk/dist/model/types' | |
import { throws } from '@zeitgeistpm/utility/dist/error' | |
import { useEffect, useState } from 'react' | |
export const MarketComponent: React.FC<{ marketId: number; sdk: Partial<Sdk<Context>> }> = ({ | |
sdk, | |
marketId, |
This file contains hidden or 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
const App: React.FC = () => { | |
const [sdk, setSdk] = useState<Partial<Sdk<Context>>>() | |
const [markets, setMarkets] = useState<Array<RpcMarket | IndexedMarket>>([]) | |
const loadMarkets = async (sdk: Sdk<Context>) => { | |
const markets = await sdk.model.markets.list() | |
setMarkets(markets) | |
} | |
useEffect(() => { |
This file contains hidden or 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
import * as ipfsClient from "ipfs-http-client"; | |
import CID from "cids"; | |
import { u8aToString } from "@polkadot/util"; | |
const main = async ( | |
metadata: string = "0x153065f773b9d3b19b9ec3ef4641bc62e714b77c086d1fa1b263331aa994789d7a8f7e21f0ceaf11ee285a2490821ca348b0" | |
) => { | |
const ipfs = await ipfsClient.create({ | |
url: "http://ipfs.zeitgeist.pm:5001/", | |
}); |
This file contains hidden or 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
const transfer = async ( | |
api: ApiPromise, | |
receiver: string, | |
ammount: number | |
): Promise< | |
| Ok<BalanceTransferEvent> | |
| Error<RejectedFees | Canceled | DispatchError | ShouldBeUnreachable> | |
> => { | |
const transaction = api.tx.balances.transfer(receiver, ammount) |
NewerOlder