import { Buffer } from "buffer"; import { AssembledTransaction, Client as ContractClient, ClientOptions as ContractClientOptions, Result, Spec as ContractSpec, } from '@stellar/stellar-sdk/minimal/contract'; import type { u32, i32, u64, i64, u128, i128, u256, i256, Option, Typepoint, Duration, } from '@stellar/stellar-sdk/minimal/contract'; if (typeof window !== 'undefined') { //@ts-ignore Buffer exists window.Buffer = window.Buffer || Buffer; } export const networks = { testnet: { networkPassphrase: "Test SDF Network ; September 2015", contractId: "NIL", } } as const export type SignerKey = { tag: "Policy", values: readonly [string] } | { tag: "Ed25519", values: readonly [Buffer] } | { tag: "Secp256r1", values: readonly [Buffer] }; export type SignerLimits = readonly [Map>>]; export type SignerStorage = { tag: "Persistent", values: void } | { tag: "Temporary", values: void }; export type Signer = { tag: "Policy", values: readonly [string, Option, SignerLimits, SignerStorage] } | { tag: "Ed25519", values: readonly [Buffer, Option, SignerLimits, SignerStorage] } | { tag: "Secp256r1", values: readonly [Buffer, Buffer, Option, SignerLimits, SignerStorage] }; export const Errors = { 1: { message: "NotInitialized" }, 2: { message: "AlreadyInitialized" } } export interface Client { /** * Construct and simulate a init transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ init: ({ wasm_hash }: { wasm_hash: Buffer }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise>> /** * Construct and simulate a deploy transaction. Returns an `AssembledTransaction` object which will have a `result` field containing the result of the simulation. If this transaction changes contract state, you will need to call `signAndSend()` on the returned object. */ deploy: ({ salt, signer }: { salt: Buffer, signer: Signer }, options?: { /** * The fee to pay for the transaction. Default: BASE_FEE */ fee?: number; /** * The maximum amount of time to wait for the transaction to complete. Default: DEFAULT_TIMEOUT */ timeoutInSeconds?: number; /** * Whether to automatically simulate the transaction when constructing the AssembledTransaction. Default: true */ simulate?: boolean; }) => Promise>> } export class Client extends ContractClient { constructor(public readonly options: ContractClientOptions) { super( new ContractSpec(["AAAAAgAAAAAAAAAAAAAACVNpZ25lcktleQAAAAAAAAMAAAABAAAAAAAAAAZQb2xpY3kAAAAAAAEAAAATAAAAAQAAAAAAAAAHRWQyNTUxOQAAAAABAAAD7gAAACAAAAABAAAAAAAAAAlTZWNwMjU2cjEAAAAAAAABAAAADg==", "AAAAAQAAAAAAAAAAAAAADFNpZ25lckxpbWl0cwAAAAEAAAAAAAAAATAAAAAAAAPsAAAAEwAAA+gAAAPqAAAH0AAAAAlTaWduZXJLZXkAAAA=", "AAAAAgAAAAAAAAAAAAAADVNpZ25lclN0b3JhZ2UAAAAAAAACAAAAAAAAAAAAAAAKUGVyc2lzdGVudAAAAAAAAAAAAAAAAAAJVGVtcG9yYXJ5AAAA", "AAAAAgAAAAAAAAAAAAAABlNpZ25lcgAAAAAAAwAAAAEAAAAAAAAABlBvbGljeQAAAAAABAAAABMAAAPoAAAABAAAB9AAAAAMU2lnbmVyTGltaXRzAAAH0AAAAA1TaWduZXJTdG9yYWdlAAAAAAAAAQAAAAAAAAAHRWQyNTUxOQAAAAAEAAAD7gAAACAAAAPoAAAABAAAB9AAAAAMU2lnbmVyTGltaXRzAAAH0AAAAA1TaWduZXJTdG9yYWdlAAAAAAAAAQAAAAAAAAAJU2VjcDI1NnIxAAAAAAAABQAAAA4AAAPuAAAAQQAAA+gAAAAEAAAH0AAAAAxTaWduZXJMaW1pdHMAAAfQAAAADVNpZ25lclN0b3JhZ2UAAAA=", "AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAAAgAAAAAAAAAOTm90SW5pdGlhbGl6ZWQAAAAAAAEAAAAAAAAAEkFscmVhZHlJbml0aWFsaXplZAAAAAAAAg==", "AAAAAAAAAAAAAAAEaW5pdAAAAAEAAAAAAAAACXdhc21faGFzaAAAAAAAA+4AAAAgAAAAAQAAA+kAAAPtAAAAAAAAAAM=", "AAAAAAAAAAAAAAAGZGVwbG95AAAAAAACAAAAAAAAAARzYWx0AAAD7gAAACAAAAAAAAAABnNpZ25lcgAAAAAH0AAAAAZTaWduZXIAAAAAAAEAAAPpAAAAEwAAAAM="]), options ) } public readonly fromJSON = { init: this.txFromJSON>, deploy: this.txFromJSON> } }