From 779f04c10930269c3a97bd8f5d16c5dfd8437e7c Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Mon, 18 Sep 2023 14:43:47 -0400 Subject: [PATCH 1/3] chore: update ts bindings What ---- Update the typescript bindings with all the changes that landed in the futurenet-compatible `smartdeploy` branch since `main` stopped working with futurenet. Why --- Lots of good improvements and fixes are not yet in `main`, ~including tests for the generated libraries.~ _CI tests will be included in a future PR; reasonable time-sink exceeded for this one. Closes: https://github.com/stellar/soroban-tools/issues/996 Known limitations ----------------- The newly-added tests are not yet being exercised in CI; you can see the commit history for all the details of how we tried to work around this. At this point, we will: - wait for https://github.com/stellar/quickstart/pull/507 to get merged & included in a published quickstart image - retry the `bindings-ts.yml` workflow, which was almost working except that friendbot was not starting properly when quickstart was run _in CI_ (though it does start properly, even if a bit slowly, when quickstart is run locally) - after a basic run-tests-with-published-quickstart is working, the next step is to build a custom quickstart image using _this repository's_ RPC version, and use that custom quickstart to run the integration tests. This might be able to be accomplished [as described by ChatGPT here](https://chat.openai.com/share/0f355fbe-93b9-4c8d-9c12-7f54846134bd). --- .gitignore | 2 - .../fixtures/test_custom_types/README.md | 4 +- .../test_custom_types/dist/cjs/convert.d.ts | 7 - .../test_custom_types/dist/cjs/convert.js | 103 --- .../test_custom_types/dist/cjs/index.d.ts | 660 ------------------ .../test_custom_types/dist/cjs/index.js | 459 ------------ .../test_custom_types/dist/cjs/invoke.d.ts | 46 -- .../test_custom_types/dist/cjs/invoke.js | 154 ---- .../dist/cjs/method-options.d.ts | 53 -- .../dist/cjs/method-options.js | 4 - .../test_custom_types/dist/esm/convert.d.ts | 7 - .../test_custom_types/dist/esm/convert.js | 94 --- .../test_custom_types/dist/esm/index.d.ts | 660 ------------------ .../test_custom_types/dist/esm/index.js | 443 ------------ .../test_custom_types/dist/esm/invoke.d.ts | 46 -- .../test_custom_types/dist/esm/invoke.js | 147 ---- .../dist/esm/method-options.d.ts | 53 -- .../dist/esm/method-options.js | 3 - .../test_custom_types/dist/esm/package.json | 1 - .../test_custom_types/dist/types/convert.d.ts | 7 - .../test_custom_types/dist/types/index.d.ts | 660 ------------------ .../test_custom_types/dist/types/invoke.d.ts | 46 -- .../dist/types/method-options.d.ts | 53 -- .../test_custom_types/package-lock.json | 189 +---- .../fixtures/test_custom_types/src/convert.ts | 8 +- .../fixtures/test_custom_types/src/index.ts | 142 ++-- .../fixtures/test_custom_types/src/invoke.ts | 18 +- .../fixtures/test_custom_types/tsconfig.json | 4 +- .../src/boilerplate.rs | 14 +- cmd/crates/soroban-spec-typescript/src/lib.rs | 26 +- .../src/project_template/src/convert.ts | 8 +- .../src/project_template/src/invoke.ts | 17 +- .../src/project_template/tsconfig.json | 4 +- .../soroban-spec-typescript/ts-tests/.env | 0 .../ts-tests/.gitignore | 3 +- .../soroban-spec-typescript/ts-tests/.nvmrc | 1 + .../ts-tests/package-lock.json | 353 +++++++++- .../ts-tests/package.json | 15 +- .../soroban-spec-typescript/ts-tests/soroban | 3 + .../src/{test.ts => test-custom-types.ts} | 32 +- .../ts-tests/src/test-hello-world.ts | 20 + .../ts-tests/src/test-methods-as-args.ts | 12 + .../ts-tests/src/util.ts | 27 + .../ts-tests/tsconfig.json | 6 +- .../test-wasms/hello_world/src/lib.rs | 6 + 45 files changed, 550 insertions(+), 4070 deletions(-) delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.js delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/package.json delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/convert.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/index.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/invoke.d.ts delete mode 100644 cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/method-options.d.ts create mode 100644 cmd/crates/soroban-spec-typescript/ts-tests/.env create mode 100644 cmd/crates/soroban-spec-typescript/ts-tests/.nvmrc create mode 100755 cmd/crates/soroban-spec-typescript/ts-tests/soroban rename cmd/crates/soroban-spec-typescript/ts-tests/src/{test.ts => test-custom-types.ts} (85%) create mode 100644 cmd/crates/soroban-spec-typescript/ts-tests/src/test-hello-world.ts create mode 100644 cmd/crates/soroban-spec-typescript/ts-tests/src/test-methods-as-args.ts create mode 100644 cmd/crates/soroban-spec-typescript/ts-tests/src/util.ts diff --git a/.gitignore b/.gitignore index 04525f117..129d79f5f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,3 @@ captive-core/ .soroban/ !test.toml *.sqlite - -cmd/crates/soroban-spec-typescript/fixtures/ts/package-lock.json diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/README.md b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/README.md index 86ef3b7e4..03f87f30b 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/README.md +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/README.md @@ -6,7 +6,7 @@ This library was automatically generated by Soroban CLI using a command similar ```bash soroban contract bindings ts \ - --rpc-url https://rpc-futurenet.stellar.org:443/soroban/rpc \ + --rpc-url https://rpc-futurenet.stellar.org:443 \ --network-passphrase "Test SDF Future Network ; October 2022" \ --contract-id CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK \ --output-dir ./path/to/test_custom_types @@ -30,7 +30,7 @@ However, we've actually encountered [frustration](https://github.com/stellar/sor ```json "scripts": { - "postinstall": "soroban contract bindings ts --rpc-url https://rpc-futurenet.stellar.org:443/soroban/rpc --network-passphrase \"Test SDF Future Network ; October 2022\" --id CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK --name test_custom_types" + "postinstall": "soroban contract bindings ts --rpc-url https://rpc-futurenet.stellar.org:443 --network-passphrase \"Test SDF Future Network ; October 2022\" --id CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK --name test_custom_types" } ``` diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.d.ts deleted file mode 100644 index 6db3b88d3..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { xdr } from 'soroban-client'; -export declare function strToScVal(base64Xdr: string): xdr.ScVal; -export declare function scValStrToJs(base64Xdr: string): T; -export declare function scValToJs(val: xdr.ScVal): T; -export declare function addressToScVal(addr: string): xdr.ScVal; -export declare function i128ToScVal(i: bigint): xdr.ScVal; -export declare function u128ToScVal(i: bigint): xdr.ScVal; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.js deleted file mode 100644 index ea86fbaf4..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/convert.js +++ /dev/null @@ -1,103 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.u128ToScVal = exports.i128ToScVal = exports.addressToScVal = exports.scValToJs = exports.scValStrToJs = exports.strToScVal = void 0; -const soroban_client_1 = require("soroban-client"); -function strToScVal(base64Xdr) { - return soroban_client_1.xdr.ScVal.fromXDR(base64Xdr, 'base64'); -} -exports.strToScVal = strToScVal; -function scValStrToJs(base64Xdr) { - return scValToJs(strToScVal(base64Xdr)); -} -exports.scValStrToJs = scValStrToJs; -function scValToJs(val) { - switch (val?.switch()) { - case soroban_client_1.xdr.ScValType.scvBool(): { - return val.b(); - } - case soroban_client_1.xdr.ScValType.scvVoid(): - case undefined: { - return 0; - } - case soroban_client_1.xdr.ScValType.scvU32(): { - return val.u32(); - } - case soroban_client_1.xdr.ScValType.scvI32(): { - return val.i32(); - } - case soroban_client_1.xdr.ScValType.scvU64(): - case soroban_client_1.xdr.ScValType.scvI64(): - case soroban_client_1.xdr.ScValType.scvU128(): - case soroban_client_1.xdr.ScValType.scvI128(): - case soroban_client_1.xdr.ScValType.scvU256(): - case soroban_client_1.xdr.ScValType.scvI256(): { - return soroban_client_1.scValToBigInt(val); - } - case soroban_client_1.xdr.ScValType.scvAddress(): { - return soroban_client_1.Address.fromScVal(val).toString(); - } - case soroban_client_1.xdr.ScValType.scvString(): { - return val.str().toString(); - } - case soroban_client_1.xdr.ScValType.scvSymbol(): { - return val.sym().toString(); - } - case soroban_client_1.xdr.ScValType.scvBytes(): { - return val.bytes(); - } - case soroban_client_1.xdr.ScValType.scvVec(): { - return val.vec().map(v => scValToJs(v)); - } - case soroban_client_1.xdr.ScValType.scvMap(): { - let res = {}; - val.map().forEach((e) => { - let key = scValToJs(e.key()); - let value; - let v = e.val(); - // For now we assume second level maps are real maps. Not perfect but better. - switch (v?.switch()) { - case soroban_client_1.xdr.ScValType.scvMap(): { - let inner_map = new Map(); - v.map().forEach((e) => { - let key = scValToJs(e.key()); - let value = scValToJs(e.val()); - inner_map.set(key, value); - }); - value = inner_map; - break; - } - default: { - value = scValToJs(e.val()); - } - } - //@ts-ignore - res[key] = value; - }); - return res; - } - case soroban_client_1.xdr.ScValType.scvContractInstance(): - case soroban_client_1.xdr.ScValType.scvLedgerKeyNonce(): - case soroban_client_1.xdr.ScValType.scvTimepoint(): - case soroban_client_1.xdr.ScValType.scvDuration(): - return val.value(); - // TODO: Add this case when merged - // case xdr.ScValType.scvError(): - default: { - throw new Error(`type not implemented yet: ${val?.switch().name}`); - } - } - ; -} -exports.scValToJs = scValToJs; -function addressToScVal(addr) { - return soroban_client_1.nativeToScVal(addr, { type: 'address' } /* bug workaround */); -} -exports.addressToScVal = addressToScVal; -function i128ToScVal(i) { - return new soroban_client_1.ScInt(i).toI128(); -} -exports.i128ToScVal = i128ToScVal; -function u128ToScVal(i) { - return new soroban_client_1.ScInt(i).toU128(); -} -exports.u128ToScVal = u128ToScVal; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.d.ts deleted file mode 100644 index afc811097..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.d.ts +++ /dev/null @@ -1,660 +0,0 @@ -import * as SorobanClient from 'soroban-client'; -import { ContractSpec, Address } from 'soroban-client'; -import { Buffer } from "buffer"; -import type { ResponseTypes, ClassOptions } from './method-options.js'; -export * from './invoke.js'; -export * from './method-options.js'; -export declare type u32 = number; -export declare type i32 = number; -export declare type u64 = bigint; -export declare type i64 = bigint; -export declare type u128 = bigint; -export declare type i128 = bigint; -export declare type u256 = bigint; -export declare type i256 = bigint; -export declare type Option = T | undefined; -export declare type Typepoint = bigint; -export declare type Duration = bigint; -export { Address }; -export interface Error_ { - message: string; -} -export interface Result { - unwrap(): T; - unwrapErr(): E; - isOk(): boolean; - isErr(): boolean; -} -export declare class Ok implements Result { - readonly value: T; - constructor(value: T); - unwrapErr(): E; - unwrap(): T; - isOk(): boolean; - isErr(): boolean; -} -export declare class Err implements Result { - readonly error: E; - constructor(error: E); - unwrapErr(): E; - unwrap(): never; - isOk(): boolean; - isErr(): boolean; -} -export declare const networks: { - readonly futurenet: { - readonly networkPassphrase: "Test SDF Future Network ; October 2022"; - readonly contractId: "CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK"; - }; -}; -/** - * This is from the rust doc above the struct Test - */ -export interface Test { - a: u32; - b: boolean; - c: string; -} -export declare type SimpleEnum = { - tag: "First"; - values: void; -} | { - tag: "Second"; - values: void; -} | { - tag: "Third"; - values: void; -}; -export declare enum RoyalCard { - Jack = 11, - Queen = 12, - King = 13 -} -export declare type TupleStruct = readonly [Test, SimpleEnum]; -export declare type ComplexEnum = { - tag: "Struct"; - values: readonly [Test]; -} | { - tag: "Tuple"; - values: readonly [TupleStruct]; -} | { - tag: "Enum"; - values: readonly [SimpleEnum]; -} | { - tag: "Asset"; - values: readonly [Address, i128]; -} | { - tag: "Void"; - values: void; -}; -export declare class Contract { - readonly options: ClassOptions; - spec: ContractSpec; - constructor(options: ClassOptions); - hello({ hello }: { - hello: string; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - woid(options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `void`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - val(options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `any`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u32FailOnEven({ u32_ }: { - u32_: u32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Ok | Err | undefined`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise | (R extends undefined ? Err | Ok : R extends "simulated" ? SorobanClient.SorobanRpc.SimulateTransactionResponse : R extends "full" ? SorobanClient.SorobanRpc.SimulateTransactionResponse | SorobanClient.SorobanRpc.SendTransactionResponse | SorobanClient.SorobanRpc.GetTransactionResponse : Err | Ok)>; - u32({ u32_ }: { - u32_: u32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i32({ i32_ }: { - i32_: i32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i64({ i64_ }: { - i64_: i64; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i64`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Example contract method which takes a struct - */ - struktHel({ strukt }: { - strukt: Test; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Array`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - strukt({ strukt }: { - strukt: Test; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Test`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - simple({ simple }: { - simple: SimpleEnum; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `SimpleEnum`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - complex({ complex }: { - complex: ComplexEnum; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `ComplexEnum`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - addresse({ addresse }: { - addresse: Address; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Address`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - bytes({ bytes }: { - bytes: Buffer; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Buffer`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - bytesN({ bytes_n }: { - bytes_n: Buffer; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Buffer`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - card({ card }: { - card: RoyalCard; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `RoyalCard`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - boolean({ boolean }: { - boolean: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `boolean`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Negates a boolean value - */ - not({ boolean }: { - boolean: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `boolean`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i128({ i128 }: { - i128: i128; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i128`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u128({ u128 }: { - u128: u128; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u128`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - multiArgs({ a, b }: { - a: u32; - b: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - map({ map }: { - map: Map; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Map`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise : R extends "simulated" ? SorobanClient.SorobanRpc.SimulateTransactionResponse : R extends "full" ? SorobanClient.SorobanRpc.SimulateTransactionResponse | SorobanClient.SorobanRpc.SendTransactionResponse | SorobanClient.SorobanRpc.GetTransactionResponse : Map>; - vec({ vec }: { - vec: Array; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Array`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - tuple({ tuple }: { - tuple: readonly [string, u32]; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `readonly [string, u32]`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Example of an optional argument - */ - option({ option }: { - option: Option; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Option`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u256({ u256 }: { - u256: u256; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u256`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i256({ i256 }: { - i256: i256; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i256`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - string({ string }: { - string: string; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - tupleStrukt({ tuple_strukt }: { - tuple_strukt: TupleStruct; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `TupleStruct`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; -} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.js deleted file mode 100644 index a03274e97..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/index.js +++ /dev/null @@ -1,459 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Contract = exports.RoyalCard = exports.networks = exports.Err = exports.Ok = exports.Address = void 0; -const soroban_client_1 = require("soroban-client"); -Object.defineProperty(exports, "Address", { enumerable: true, get: function () { return soroban_client_1.Address; } }); -const buffer_1 = require("buffer"); -const invoke_js_1 = require("./invoke.js"); -__exportStar(require("./invoke.js"), exports); -__exportStar(require("./method-options.js"), exports); -; -; -class Ok { - constructor(value) { - this.value = value; - } - unwrapErr() { - throw new Error('No error'); - } - unwrap() { - return this.value; - } - isOk() { - return true; - } - isErr() { - return !this.isOk(); - } -} -exports.Ok = Ok; -class Err { - constructor(error) { - this.error = error; - } - unwrapErr() { - return this.error; - } - unwrap() { - throw new Error(this.error.message); - } - isOk() { - return false; - } - isErr() { - return !this.isOk(); - } -} -exports.Err = Err; -if (typeof window !== 'undefined') { - //@ts-ignore Buffer exists - window.Buffer = window.Buffer || buffer_1.Buffer; -} -const regex = /Error\(Contract, #(\d+)\)/; -function parseError(message) { - const match = message.match(regex); - if (!match) { - return undefined; - } - if (Errors === undefined) { - return undefined; - } - let i = parseInt(match[1], 10); - let err = Errors[i]; - if (err) { - return new Err(err); - } - return undefined; -} -exports.networks = { - futurenet: { - networkPassphrase: "Test SDF Future Network ; October 2022", - contractId: "CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK", - } -}; -var RoyalCard; -(function (RoyalCard) { - RoyalCard[RoyalCard["Jack"] = 11] = "Jack"; - RoyalCard[RoyalCard["Queen"] = 12] = "Queen"; - RoyalCard[RoyalCard["King"] = 13] = "King"; -})(RoyalCard = exports.RoyalCard || (exports.RoyalCard = {})); -const Errors = { - 1: { message: "Please provide an odd number" } -}; -class Contract { - constructor(options) { - this.options = options; - this.spec = new soroban_client_1.ContractSpec([ - "AAAAAQAAAC9UaGlzIGlzIGZyb20gdGhlIHJ1c3QgZG9jIGFib3ZlIHRoZSBzdHJ1Y3QgVGVzdAAAAAAAAAAABFRlc3QAAAADAAAAAAAAAAFhAAAAAAAABAAAAAAAAAABYgAAAAAAAAEAAAAAAAAAAWMAAAAAAAAR", - "AAAAAgAAAAAAAAAAAAAAClNpbXBsZUVudW0AAAAAAAMAAAAAAAAAAAAAAAVGaXJzdAAAAAAAAAAAAAAAAAAABlNlY29uZAAAAAAAAAAAAAAAAAAFVGhpcmQAAAA=", - "AAAAAwAAAAAAAAAAAAAACVJveWFsQ2FyZAAAAAAAAAMAAAAAAAAABEphY2sAAAALAAAAAAAAAAVRdWVlbgAAAAAAAAwAAAAAAAAABEtpbmcAAAAN", - "AAAAAQAAAAAAAAAAAAAAC1R1cGxlU3RydWN0AAAAAAIAAAAAAAAAATAAAAAAAAfQAAAABFRlc3QAAAAAAAAAATEAAAAAAAfQAAAAClNpbXBsZUVudW0AAA==", - "AAAAAgAAAAAAAAAAAAAAC0NvbXBsZXhFbnVtAAAAAAUAAAABAAAAAAAAAAZTdHJ1Y3QAAAAAAAEAAAfQAAAABFRlc3QAAAABAAAAAAAAAAVUdXBsZQAAAAAAAAEAAAfQAAAAC1R1cGxlU3RydWN0AAAAAAEAAAAAAAAABEVudW0AAAABAAAH0AAAAApTaW1wbGVFbnVtAAAAAAABAAAAAAAAAAVBc3NldAAAAAAAAAIAAAATAAAACwAAAAAAAAAAAAAABFZvaWQ=", - "AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAAAQAAABxQbGVhc2UgcHJvdmlkZSBhbiBvZGQgbnVtYmVyAAAAD051bWJlck11c3RCZU9kZAAAAAAB", - "AAAAAAAAAAAAAAAFaGVsbG8AAAAAAAABAAAAAAAAAAVoZWxsbwAAAAAAABEAAAABAAAAEQ==", - "AAAAAAAAAAAAAAAEd29pZAAAAAAAAAAA", - "AAAAAAAAAAAAAAADdmFsAAAAAAAAAAABAAAAAA==", - "AAAAAAAAAAAAAAAQdTMyX2ZhaWxfb25fZXZlbgAAAAEAAAAAAAAABHUzMl8AAAAEAAAAAQAAA+kAAAAEAAAAAw==", - "AAAAAAAAAAAAAAAEdTMyXwAAAAEAAAAAAAAABHUzMl8AAAAEAAAAAQAAAAQ=", - "AAAAAAAAAAAAAAAEaTMyXwAAAAEAAAAAAAAABGkzMl8AAAAFAAAAAQAAAAU=", - "AAAAAAAAAAAAAAAEaTY0XwAAAAEAAAAAAAAABGk2NF8AAAAHAAAAAQAAAAc=", - "AAAAAAAAACxFeGFtcGxlIGNvbnRyYWN0IG1ldGhvZCB3aGljaCB0YWtlcyBhIHN0cnVjdAAAAApzdHJ1a3RfaGVsAAAAAAABAAAAAAAAAAZzdHJ1a3QAAAAAB9AAAAAEVGVzdAAAAAEAAAPqAAAAEQ==", - "AAAAAAAAAAAAAAAGc3RydWt0AAAAAAABAAAAAAAAAAZzdHJ1a3QAAAAAB9AAAAAEVGVzdAAAAAEAAAfQAAAABFRlc3Q=", - "AAAAAAAAAAAAAAAGc2ltcGxlAAAAAAABAAAAAAAAAAZzaW1wbGUAAAAAB9AAAAAKU2ltcGxlRW51bQAAAAAAAQAAB9AAAAAKU2ltcGxlRW51bQAA", - "AAAAAAAAAAAAAAAHY29tcGxleAAAAAABAAAAAAAAAAdjb21wbGV4AAAAB9AAAAALQ29tcGxleEVudW0AAAAAAQAAB9AAAAALQ29tcGxleEVudW0A", - "AAAAAAAAAAAAAAAIYWRkcmVzc2UAAAABAAAAAAAAAAhhZGRyZXNzZQAAABMAAAABAAAAEw==", - "AAAAAAAAAAAAAAAFYnl0ZXMAAAAAAAABAAAAAAAAAAVieXRlcwAAAAAAAA4AAAABAAAADg==", - "AAAAAAAAAAAAAAAHYnl0ZXNfbgAAAAABAAAAAAAAAAdieXRlc19uAAAAA+4AAAAJAAAAAQAAA+4AAAAJ", - "AAAAAAAAAAAAAAAEY2FyZAAAAAEAAAAAAAAABGNhcmQAAAfQAAAACVJveWFsQ2FyZAAAAAAAAAEAAAfQAAAACVJveWFsQ2FyZAAAAA==", - "AAAAAAAAAAAAAAAHYm9vbGVhbgAAAAABAAAAAAAAAAdib29sZWFuAAAAAAEAAAABAAAAAQ==", - "AAAAAAAAABdOZWdhdGVzIGEgYm9vbGVhbiB2YWx1ZQAAAAADbm90AAAAAAEAAAAAAAAAB2Jvb2xlYW4AAAAAAQAAAAEAAAAB", - "AAAAAAAAAAAAAAAEaTEyOAAAAAEAAAAAAAAABGkxMjgAAAALAAAAAQAAAAs=", - "AAAAAAAAAAAAAAAEdTEyOAAAAAEAAAAAAAAABHUxMjgAAAAKAAAAAQAAAAo=", - "AAAAAAAAAAAAAAAKbXVsdGlfYXJncwAAAAAAAgAAAAAAAAABYQAAAAAAAAQAAAAAAAAAAWIAAAAAAAABAAAAAQAAAAQ=", - "AAAAAAAAAAAAAAADbWFwAAAAAAEAAAAAAAAAA21hcAAAAAPsAAAABAAAAAEAAAABAAAD7AAAAAQAAAAB", - "AAAAAAAAAAAAAAADdmVjAAAAAAEAAAAAAAAAA3ZlYwAAAAPqAAAABAAAAAEAAAPqAAAABA==", - "AAAAAAAAAAAAAAAFdHVwbGUAAAAAAAABAAAAAAAAAAV0dXBsZQAAAAAAA+0AAAACAAAAEQAAAAQAAAABAAAD7QAAAAIAAAARAAAABA==", - "AAAAAAAAAB9FeGFtcGxlIG9mIGFuIG9wdGlvbmFsIGFyZ3VtZW50AAAAAAZvcHRpb24AAAAAAAEAAAAAAAAABm9wdGlvbgAAAAAD6AAAAAQAAAABAAAD6AAAAAQ=", - "AAAAAAAAAAAAAAAEdTI1NgAAAAEAAAAAAAAABHUyNTYAAAAMAAAAAQAAAAw=", - "AAAAAAAAAAAAAAAEaTI1NgAAAAEAAAAAAAAABGkyNTYAAAANAAAAAQAAAA0=", - "AAAAAAAAAAAAAAAGc3RyaW5nAAAAAAABAAAAAAAAAAZzdHJpbmcAAAAAABAAAAABAAAAEA==", - "AAAAAAAAAAAAAAAMdHVwbGVfc3RydWt0AAAAAQAAAAAAAAAMdHVwbGVfc3RydWt0AAAH0AAAAAtUdXBsZVN0cnVjdAAAAAABAAAH0AAAAAtUdXBsZVN0cnVjdAA=" - ]); - } - async hello({ hello }, options = {}) { - return await invoke_js_1.invoke({ - method: 'hello', - args: this.spec.funcArgsToScVals("hello", { hello }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("hello", xdr); - }, - }); - } - async woid(options = {}) { - return await invoke_js_1.invoke({ - method: 'woid', - args: this.spec.funcArgsToScVals("woid", {}), - ...options, - ...this.options, - parseResultXdr: () => { }, - }); - } - async val(options = {}) { - return await invoke_js_1.invoke({ - method: 'val', - args: this.spec.funcArgsToScVals("val", {}), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("val", xdr); - }, - }); - } - async u32FailOnEven({ u32_ }, options = {}) { - try { - return await invoke_js_1.invoke({ - method: 'u32_fail_on_even', - args: this.spec.funcArgsToScVals("u32_fail_on_even", { u32_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return new Ok(this.spec.funcResToNative("u32_fail_on_even", xdr)); - }, - }); - } - catch (e) { - if (typeof e === 'string') { - let err = parseError(e); - if (err) - return err; - } - throw e; - } - } - async u32({ u32_ }, options = {}) { - return await invoke_js_1.invoke({ - method: 'u32_', - args: this.spec.funcArgsToScVals("u32_", { u32_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("u32_", xdr); - }, - }); - } - async i32({ i32_ }, options = {}) { - return await invoke_js_1.invoke({ - method: 'i32_', - args: this.spec.funcArgsToScVals("i32_", { i32_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i32_", xdr); - }, - }); - } - async i64({ i64_ }, options = {}) { - return await invoke_js_1.invoke({ - method: 'i64_', - args: this.spec.funcArgsToScVals("i64_", { i64_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i64_", xdr); - }, - }); - } - /** - * Example contract method which takes a struct - */ - async struktHel({ strukt }, options = {}) { - return await invoke_js_1.invoke({ - method: 'strukt_hel', - args: this.spec.funcArgsToScVals("strukt_hel", { strukt }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("strukt_hel", xdr); - }, - }); - } - async strukt({ strukt }, options = {}) { - return await invoke_js_1.invoke({ - method: 'strukt', - args: this.spec.funcArgsToScVals("strukt", { strukt }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("strukt", xdr); - }, - }); - } - async simple({ simple }, options = {}) { - return await invoke_js_1.invoke({ - method: 'simple', - args: this.spec.funcArgsToScVals("simple", { simple }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("simple", xdr); - }, - }); - } - async complex({ complex }, options = {}) { - return await invoke_js_1.invoke({ - method: 'complex', - args: this.spec.funcArgsToScVals("complex", { complex }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("complex", xdr); - }, - }); - } - async addresse({ addresse }, options = {}) { - return await invoke_js_1.invoke({ - method: 'addresse', - args: this.spec.funcArgsToScVals("addresse", { addresse }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("addresse", xdr); - }, - }); - } - async bytes({ bytes }, options = {}) { - return await invoke_js_1.invoke({ - method: 'bytes', - args: this.spec.funcArgsToScVals("bytes", { bytes }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("bytes", xdr); - }, - }); - } - async bytesN({ bytes_n }, options = {}) { - return await invoke_js_1.invoke({ - method: 'bytes_n', - args: this.spec.funcArgsToScVals("bytes_n", { bytes_n }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("bytes_n", xdr); - }, - }); - } - async card({ card }, options = {}) { - return await invoke_js_1.invoke({ - method: 'card', - args: this.spec.funcArgsToScVals("card", { card }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("card", xdr); - }, - }); - } - async boolean({ boolean }, options = {}) { - return await invoke_js_1.invoke({ - method: 'boolean', - args: this.spec.funcArgsToScVals("boolean", { boolean }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("boolean", xdr); - }, - }); - } - /** - * Negates a boolean value - */ - async not({ boolean }, options = {}) { - return await invoke_js_1.invoke({ - method: 'not', - args: this.spec.funcArgsToScVals("not", { boolean }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("not", xdr); - }, - }); - } - async i128({ i128 }, options = {}) { - return await invoke_js_1.invoke({ - method: 'i128', - args: this.spec.funcArgsToScVals("i128", { i128 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i128", xdr); - }, - }); - } - async u128({ u128 }, options = {}) { - return await invoke_js_1.invoke({ - method: 'u128', - args: this.spec.funcArgsToScVals("u128", { u128 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("u128", xdr); - }, - }); - } - async multiArgs({ a, b }, options = {}) { - return await invoke_js_1.invoke({ - method: 'multi_args', - args: this.spec.funcArgsToScVals("multi_args", { a, b }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("multi_args", xdr); - }, - }); - } - async map({ map }, options = {}) { - return await invoke_js_1.invoke({ - method: 'map', - args: this.spec.funcArgsToScVals("map", { map }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("map", xdr); - }, - }); - } - async vec({ vec }, options = {}) { - return await invoke_js_1.invoke({ - method: 'vec', - args: this.spec.funcArgsToScVals("vec", { vec }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("vec", xdr); - }, - }); - } - async tuple({ tuple }, options = {}) { - return await invoke_js_1.invoke({ - method: 'tuple', - args: this.spec.funcArgsToScVals("tuple", { tuple }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("tuple", xdr); - }, - }); - } - /** - * Example of an optional argument - */ - async option({ option }, options = {}) { - return await invoke_js_1.invoke({ - method: 'option', - args: this.spec.funcArgsToScVals("option", { option }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("option", xdr); - }, - }); - } - async u256({ u256 }, options = {}) { - return await invoke_js_1.invoke({ - method: 'u256', - args: this.spec.funcArgsToScVals("u256", { u256 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("u256", xdr); - }, - }); - } - async i256({ i256 }, options = {}) { - return await invoke_js_1.invoke({ - method: 'i256', - args: this.spec.funcArgsToScVals("i256", { i256 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i256", xdr); - }, - }); - } - async string({ string }, options = {}) { - return await invoke_js_1.invoke({ - method: 'string', - args: this.spec.funcArgsToScVals("string", { string }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("string", xdr); - }, - }); - } - async tupleStrukt({ tuple_strukt }, options = {}) { - return await invoke_js_1.invoke({ - method: 'tuple_strukt', - args: this.spec.funcArgsToScVals("tuple_strukt", { tuple_strukt }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("tuple_strukt", xdr); - }, - }); - } -} -exports.Contract = Contract; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.d.ts deleted file mode 100644 index 1934a69a6..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as SorobanClient from "soroban-client"; -import { SorobanRpc } from "soroban-client"; -import type { Memo, MemoType, Operation, Transaction, xdr } from "soroban-client"; -import type { ClassOptions, MethodOptions, ResponseTypes, Wallet } from "./method-options.js"; -export declare type Tx = Transaction, Operation[]>; -export declare class NotImplementedError extends Error { -} -declare type Simulation = SorobanRpc.SimulateTransactionResponse; -declare type SendTx = SorobanRpc.SendTransactionResponse; -declare type GetTx = SorobanRpc.GetTransactionResponse; -declare let someRpcResponse: Simulation | SendTx | GetTx; -declare type SomeRpcResponse = typeof someRpcResponse; -declare type InvokeArgs = MethodOptions & ClassOptions & { - method: string; - args?: any[]; - parseResultXdr: (xdr: string | xdr.ScVal) => T; -}; -/** - * Invoke a method on the test_custom_types contract. - * - * Uses Freighter to determine the current user and if necessary sign the transaction. - * - * @returns {T}, by default, the parsed XDR from either the simulation or the full transaction. If `simulateOnly` or `fullRpcResponse` are true, returns either the full simulation or the result of sending/getting the transaction to/from the ledger. - */ -export declare function invoke(args: InvokeArgs): Promise; -/** - * Sign a transaction with Freighter and return the fully-reconstructed - * transaction ready to send with {@link sendTx}. - * - * If you need to construct a transaction yourself rather than using `invoke` - * or one of the exported contract methods, you may want to use this function - * to sign the transaction with Freighter. - */ -export declare function signTx(wallet: Wallet, tx: Tx, networkPassphrase: string): Promise; -/** - * Send a transaction to the Soroban network. - * - * Wait `secondsToWait` seconds for the transaction to complete (default: 10). - * - * If you need to construct or sign a transaction yourself rather than using - * `invoke` or one of the exported contract methods, you may want to use this - * function for its timeout/`secondsToWait` logic, rather than implementing - * your own. - */ -export declare function sendTx(tx: Tx, secondsToWait: number, server: SorobanClient.Server): Promise; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.js deleted file mode 100644 index c6e606fe5..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/invoke.js +++ /dev/null @@ -1,154 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.sendTx = exports.signTx = exports.invoke = exports.NotImplementedError = void 0; -const SorobanClient = require("soroban-client"); -const soroban_client_1 = require("soroban-client"); -/** - * Get account details from the Soroban network for the publicKey currently - * selected in Freighter. If not connected to Freighter, return null. - */ -async function getAccount(wallet, server) { - if (!(await wallet.isConnected()) || !(await wallet.isAllowed())) { - return null; - } - const { publicKey } = await wallet.getUserInfo(); - if (!publicKey) { - return null; - } - return await server.getAccount(publicKey); -} -class NotImplementedError extends Error { -} -exports.NotImplementedError = NotImplementedError; -// defined this way so typeahead shows full union, not named alias -let someRpcResponse; -async function invoke({ method, args = [], fee = 100, responseType, parseResultXdr, secondsToWait = 10, rpcUrl, networkPassphrase, contractId, wallet, }) { - wallet = wallet ?? (await Promise.resolve().then(() => require("@stellar/freighter-api"))); - let parse = parseResultXdr; - const server = new SorobanClient.Server(rpcUrl, { - allowHttp: rpcUrl.startsWith("http://"), - }); - const walletAccount = await getAccount(wallet, server); - // use a placeholder null account if not yet connected to Freighter so that view calls can still work - const account = walletAccount ?? - new SorobanClient.Account("GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF", "0"); - const contract = new SorobanClient.Contract(contractId); - let tx = new SorobanClient.TransactionBuilder(account, { - fee: fee.toString(10), - networkPassphrase, - }) - .setNetworkPassphrase(networkPassphrase) - .addOperation(contract.call(method, ...args)) - .setTimeout(SorobanClient.TimeoutInfinite) - .build(); - const simulated = await server.simulateTransaction(tx); - if (soroban_client_1.SorobanRpc.isSimulationError(simulated)) { - throw new Error(simulated.error); - } - else if (responseType === "simulated") { - return simulated; - } - else if (!simulated.result) { - throw new Error(`invalid simulation: no result in ${simulated}`); - } - let authsCount = simulated.result.auth.length; - const writeLength = simulated.transactionData.getReadWrite().length; - const isViewCall = (authsCount === 0) && (writeLength === 0); - if (isViewCall) { - if (responseType === "full") { - return simulated; - } - return parseResultXdr(simulated.result.retval); - } - if (authsCount > 1) { - throw new NotImplementedError("Multiple auths not yet supported"); - } - if (authsCount === 1) { - // TODO: figure out how to fix with new SorobanClient - // const auth = SorobanClient.xdr.SorobanAuthorizationEntry.fromXDR(auths![0]!, 'base64') - // if (auth.addressWithNonce() !== undefined) { - // throw new NotImplementedError( - // `This transaction needs to be signed by ${auth.addressWithNonce() - // }; Not yet supported` - // ) - // } - } - if (!walletAccount) { - throw new Error("Not connected to Freighter"); - } - tx = await signTx(wallet, SorobanClient.assembleTransaction(tx, networkPassphrase, simulated).build(), networkPassphrase); - const raw = await sendTx(tx, secondsToWait, server); - if (responseType === "full") { - return raw; - } - // if `sendTx` awaited the inclusion of the tx in the ledger, it used - // `getTransaction`, which has a `resultXdr` field - if ("resultXdr" in raw) { - const getResult = raw; - if (getResult.status !== soroban_client_1.SorobanRpc.GetTransactionStatus.SUCCESS) { - console.error('Transaction submission failed! Returning full RPC response.'); - return raw; - } - return parse(raw.resultXdr.result().toXDR("base64")); - } - // otherwise, it returned the result of `sendTransaction` - if ("errorResultXdr" in raw) { - const sendResult = raw; - return parse(sendResult.errorResultXdr); - } - // if neither of these are present, something went wrong - console.error("Don't know how to parse result! Returning full RPC response."); - return raw; -} -exports.invoke = invoke; -/** - * Sign a transaction with Freighter and return the fully-reconstructed - * transaction ready to send with {@link sendTx}. - * - * If you need to construct a transaction yourself rather than using `invoke` - * or one of the exported contract methods, you may want to use this function - * to sign the transaction with Freighter. - */ -async function signTx(wallet, tx, networkPassphrase) { - const signed = await wallet.signTransaction(tx.toXDR(), { - networkPassphrase, - }); - return SorobanClient.TransactionBuilder.fromXDR(signed, networkPassphrase); -} -exports.signTx = signTx; -/** - * Send a transaction to the Soroban network. - * - * Wait `secondsToWait` seconds for the transaction to complete (default: 10). - * - * If you need to construct or sign a transaction yourself rather than using - * `invoke` or one of the exported contract methods, you may want to use this - * function for its timeout/`secondsToWait` logic, rather than implementing - * your own. - */ -async function sendTx(tx, secondsToWait, server) { - const sendTransactionResponse = await server.sendTransaction(tx); - if (sendTransactionResponse.status !== "PENDING" || secondsToWait === 0) { - return sendTransactionResponse; - } - let getTransactionResponse = await server.getTransaction(sendTransactionResponse.hash); - const waitUntil = new Date(Date.now() + secondsToWait * 1000).valueOf(); - let waitTime = 1000; - let exponentialFactor = 1.5; - while (Date.now() < waitUntil && - getTransactionResponse.status === soroban_client_1.SorobanRpc.GetTransactionStatus.NOT_FOUND) { - // Wait a beat - await new Promise((resolve) => setTimeout(resolve, waitTime)); - /// Exponential backoff - waitTime = waitTime * exponentialFactor; - // See if the transaction is complete - getTransactionResponse = await server.getTransaction(sendTransactionResponse.hash); - } - if (getTransactionResponse.status === soroban_client_1.SorobanRpc.GetTransactionStatus.NOT_FOUND) { - console.error(`Waited ${secondsToWait} seconds for transaction to complete, but it did not. ` + - `Returning anyway. Check the transaction status manually. ` + - `Info: ${JSON.stringify(sendTransactionResponse, null, 2)}`); - } - return getTransactionResponse; -} -exports.sendTx = sendTx; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.d.ts deleted file mode 100644 index a959d97f2..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -declare let responseTypes: 'simulated' | 'full' | undefined; -export declare type ResponseTypes = typeof responseTypes; -export declare type XDR_BASE64 = string; -export interface Wallet { - isConnected: () => Promise; - isAllowed: () => Promise; - getUserInfo: () => Promise<{ - publicKey?: string; - }>; - signTransaction: (tx: XDR_BASE64, opts?: { - network?: string; - networkPassphrase?: string; - accountToSign?: string; - }) => Promise; -} -export declare type ClassOptions = { - contractId: string; - networkPassphrase: string; - rpcUrl: string; - /** - * A Wallet interface, such as Freighter, that has the methods `isConnected`, `isAllowed`, `getUserInfo`, and `signTransaction`. If not provided, will attempt to import and use Freighter. Example: - * - * @example - * ```ts - * import freighter from "@stellar/freighter-api"; - * import { Contract } from "test_custom_types"; - * const contract = new Contract({ - * …, - * wallet: freighter, - * }) - * ``` - */ - wallet?: Wallet; -}; -export declare type MethodOptions = { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `{RETURN_TYPE}`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; -}; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.js deleted file mode 100644 index 6d483ac32..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/cjs/method-options.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// defined this way so typeahead shows full union, not named alias -let responseTypes; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.d.ts deleted file mode 100644 index 6db3b88d3..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { xdr } from 'soroban-client'; -export declare function strToScVal(base64Xdr: string): xdr.ScVal; -export declare function scValStrToJs(base64Xdr: string): T; -export declare function scValToJs(val: xdr.ScVal): T; -export declare function addressToScVal(addr: string): xdr.ScVal; -export declare function i128ToScVal(i: bigint): xdr.ScVal; -export declare function u128ToScVal(i: bigint): xdr.ScVal; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.js deleted file mode 100644 index 4faf03e15..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/convert.js +++ /dev/null @@ -1,94 +0,0 @@ -import { xdr, Address, nativeToScVal, scValToBigInt, ScInt } from 'soroban-client'; -export function strToScVal(base64Xdr) { - return xdr.ScVal.fromXDR(base64Xdr, 'base64'); -} -export function scValStrToJs(base64Xdr) { - return scValToJs(strToScVal(base64Xdr)); -} -export function scValToJs(val) { - switch (val?.switch()) { - case xdr.ScValType.scvBool(): { - return val.b(); - } - case xdr.ScValType.scvVoid(): - case undefined: { - return 0; - } - case xdr.ScValType.scvU32(): { - return val.u32(); - } - case xdr.ScValType.scvI32(): { - return val.i32(); - } - case xdr.ScValType.scvU64(): - case xdr.ScValType.scvI64(): - case xdr.ScValType.scvU128(): - case xdr.ScValType.scvI128(): - case xdr.ScValType.scvU256(): - case xdr.ScValType.scvI256(): { - return scValToBigInt(val); - } - case xdr.ScValType.scvAddress(): { - return Address.fromScVal(val).toString(); - } - case xdr.ScValType.scvString(): { - return val.str().toString(); - } - case xdr.ScValType.scvSymbol(): { - return val.sym().toString(); - } - case xdr.ScValType.scvBytes(): { - return val.bytes(); - } - case xdr.ScValType.scvVec(): { - return val.vec().map(v => scValToJs(v)); - } - case xdr.ScValType.scvMap(): { - let res = {}; - val.map().forEach((e) => { - let key = scValToJs(e.key()); - let value; - let v = e.val(); - // For now we assume second level maps are real maps. Not perfect but better. - switch (v?.switch()) { - case xdr.ScValType.scvMap(): { - let inner_map = new Map(); - v.map().forEach((e) => { - let key = scValToJs(e.key()); - let value = scValToJs(e.val()); - inner_map.set(key, value); - }); - value = inner_map; - break; - } - default: { - value = scValToJs(e.val()); - } - } - //@ts-ignore - res[key] = value; - }); - return res; - } - case xdr.ScValType.scvContractInstance(): - case xdr.ScValType.scvLedgerKeyNonce(): - case xdr.ScValType.scvTimepoint(): - case xdr.ScValType.scvDuration(): - return val.value(); - // TODO: Add this case when merged - // case xdr.ScValType.scvError(): - default: { - throw new Error(`type not implemented yet: ${val?.switch().name}`); - } - } - ; -} -export function addressToScVal(addr) { - return nativeToScVal(addr, { type: 'address' } /* bug workaround */); -} -export function i128ToScVal(i) { - return new ScInt(i).toI128(); -} -export function u128ToScVal(i) { - return new ScInt(i).toU128(); -} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.d.ts deleted file mode 100644 index afc811097..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.d.ts +++ /dev/null @@ -1,660 +0,0 @@ -import * as SorobanClient from 'soroban-client'; -import { ContractSpec, Address } from 'soroban-client'; -import { Buffer } from "buffer"; -import type { ResponseTypes, ClassOptions } from './method-options.js'; -export * from './invoke.js'; -export * from './method-options.js'; -export declare type u32 = number; -export declare type i32 = number; -export declare type u64 = bigint; -export declare type i64 = bigint; -export declare type u128 = bigint; -export declare type i128 = bigint; -export declare type u256 = bigint; -export declare type i256 = bigint; -export declare type Option = T | undefined; -export declare type Typepoint = bigint; -export declare type Duration = bigint; -export { Address }; -export interface Error_ { - message: string; -} -export interface Result { - unwrap(): T; - unwrapErr(): E; - isOk(): boolean; - isErr(): boolean; -} -export declare class Ok implements Result { - readonly value: T; - constructor(value: T); - unwrapErr(): E; - unwrap(): T; - isOk(): boolean; - isErr(): boolean; -} -export declare class Err implements Result { - readonly error: E; - constructor(error: E); - unwrapErr(): E; - unwrap(): never; - isOk(): boolean; - isErr(): boolean; -} -export declare const networks: { - readonly futurenet: { - readonly networkPassphrase: "Test SDF Future Network ; October 2022"; - readonly contractId: "CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK"; - }; -}; -/** - * This is from the rust doc above the struct Test - */ -export interface Test { - a: u32; - b: boolean; - c: string; -} -export declare type SimpleEnum = { - tag: "First"; - values: void; -} | { - tag: "Second"; - values: void; -} | { - tag: "Third"; - values: void; -}; -export declare enum RoyalCard { - Jack = 11, - Queen = 12, - King = 13 -} -export declare type TupleStruct = readonly [Test, SimpleEnum]; -export declare type ComplexEnum = { - tag: "Struct"; - values: readonly [Test]; -} | { - tag: "Tuple"; - values: readonly [TupleStruct]; -} | { - tag: "Enum"; - values: readonly [SimpleEnum]; -} | { - tag: "Asset"; - values: readonly [Address, i128]; -} | { - tag: "Void"; - values: void; -}; -export declare class Contract { - readonly options: ClassOptions; - spec: ContractSpec; - constructor(options: ClassOptions); - hello({ hello }: { - hello: string; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - woid(options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `void`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - val(options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `any`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u32FailOnEven({ u32_ }: { - u32_: u32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Ok | Err | undefined`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise | (R extends undefined ? Err | Ok : R extends "simulated" ? SorobanClient.SorobanRpc.SimulateTransactionResponse : R extends "full" ? SorobanClient.SorobanRpc.SimulateTransactionResponse | SorobanClient.SorobanRpc.SendTransactionResponse | SorobanClient.SorobanRpc.GetTransactionResponse : Err | Ok)>; - u32({ u32_ }: { - u32_: u32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i32({ i32_ }: { - i32_: i32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i64({ i64_ }: { - i64_: i64; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i64`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Example contract method which takes a struct - */ - struktHel({ strukt }: { - strukt: Test; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Array`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - strukt({ strukt }: { - strukt: Test; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Test`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - simple({ simple }: { - simple: SimpleEnum; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `SimpleEnum`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - complex({ complex }: { - complex: ComplexEnum; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `ComplexEnum`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - addresse({ addresse }: { - addresse: Address; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Address`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - bytes({ bytes }: { - bytes: Buffer; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Buffer`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - bytesN({ bytes_n }: { - bytes_n: Buffer; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Buffer`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - card({ card }: { - card: RoyalCard; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `RoyalCard`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - boolean({ boolean }: { - boolean: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `boolean`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Negates a boolean value - */ - not({ boolean }: { - boolean: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `boolean`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i128({ i128 }: { - i128: i128; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i128`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u128({ u128 }: { - u128: u128; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u128`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - multiArgs({ a, b }: { - a: u32; - b: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - map({ map }: { - map: Map; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Map`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise : R extends "simulated" ? SorobanClient.SorobanRpc.SimulateTransactionResponse : R extends "full" ? SorobanClient.SorobanRpc.SimulateTransactionResponse | SorobanClient.SorobanRpc.SendTransactionResponse | SorobanClient.SorobanRpc.GetTransactionResponse : Map>; - vec({ vec }: { - vec: Array; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Array`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - tuple({ tuple }: { - tuple: readonly [string, u32]; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `readonly [string, u32]`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Example of an optional argument - */ - option({ option }: { - option: Option; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Option`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u256({ u256 }: { - u256: u256; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u256`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i256({ i256 }: { - i256: i256; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i256`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - string({ string }: { - string: string; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - tupleStrukt({ tuple_strukt }: { - tuple_strukt: TupleStruct; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `TupleStruct`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; -} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.js deleted file mode 100644 index 9b6aab750..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/index.js +++ /dev/null @@ -1,443 +0,0 @@ -import { ContractSpec, Address } from 'soroban-client'; -import { Buffer } from "buffer"; -import { invoke } from './invoke.js'; -export * from './invoke.js'; -export * from './method-options.js'; -export { Address }; -; -; -export class Ok { - constructor(value) { - this.value = value; - } - unwrapErr() { - throw new Error('No error'); - } - unwrap() { - return this.value; - } - isOk() { - return true; - } - isErr() { - return !this.isOk(); - } -} -export class Err { - constructor(error) { - this.error = error; - } - unwrapErr() { - return this.error; - } - unwrap() { - throw new Error(this.error.message); - } - isOk() { - return false; - } - isErr() { - return !this.isOk(); - } -} -if (typeof window !== 'undefined') { - //@ts-ignore Buffer exists - window.Buffer = window.Buffer || Buffer; -} -const regex = /Error\(Contract, #(\d+)\)/; -function parseError(message) { - const match = message.match(regex); - if (!match) { - return undefined; - } - if (Errors === undefined) { - return undefined; - } - let i = parseInt(match[1], 10); - let err = Errors[i]; - if (err) { - return new Err(err); - } - return undefined; -} -export const networks = { - futurenet: { - networkPassphrase: "Test SDF Future Network ; October 2022", - contractId: "CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK", - } -}; -export var RoyalCard; -(function (RoyalCard) { - RoyalCard[RoyalCard["Jack"] = 11] = "Jack"; - RoyalCard[RoyalCard["Queen"] = 12] = "Queen"; - RoyalCard[RoyalCard["King"] = 13] = "King"; -})(RoyalCard || (RoyalCard = {})); -const Errors = { - 1: { message: "Please provide an odd number" } -}; -export class Contract { - constructor(options) { - this.options = options; - this.spec = new ContractSpec([ - "AAAAAQAAAC9UaGlzIGlzIGZyb20gdGhlIHJ1c3QgZG9jIGFib3ZlIHRoZSBzdHJ1Y3QgVGVzdAAAAAAAAAAABFRlc3QAAAADAAAAAAAAAAFhAAAAAAAABAAAAAAAAAABYgAAAAAAAAEAAAAAAAAAAWMAAAAAAAAR", - "AAAAAgAAAAAAAAAAAAAAClNpbXBsZUVudW0AAAAAAAMAAAAAAAAAAAAAAAVGaXJzdAAAAAAAAAAAAAAAAAAABlNlY29uZAAAAAAAAAAAAAAAAAAFVGhpcmQAAAA=", - "AAAAAwAAAAAAAAAAAAAACVJveWFsQ2FyZAAAAAAAAAMAAAAAAAAABEphY2sAAAALAAAAAAAAAAVRdWVlbgAAAAAAAAwAAAAAAAAABEtpbmcAAAAN", - "AAAAAQAAAAAAAAAAAAAAC1R1cGxlU3RydWN0AAAAAAIAAAAAAAAAATAAAAAAAAfQAAAABFRlc3QAAAAAAAAAATEAAAAAAAfQAAAAClNpbXBsZUVudW0AAA==", - "AAAAAgAAAAAAAAAAAAAAC0NvbXBsZXhFbnVtAAAAAAUAAAABAAAAAAAAAAZTdHJ1Y3QAAAAAAAEAAAfQAAAABFRlc3QAAAABAAAAAAAAAAVUdXBsZQAAAAAAAAEAAAfQAAAAC1R1cGxlU3RydWN0AAAAAAEAAAAAAAAABEVudW0AAAABAAAH0AAAAApTaW1wbGVFbnVtAAAAAAABAAAAAAAAAAVBc3NldAAAAAAAAAIAAAATAAAACwAAAAAAAAAAAAAABFZvaWQ=", - "AAAABAAAAAAAAAAAAAAABUVycm9yAAAAAAAAAQAAABxQbGVhc2UgcHJvdmlkZSBhbiBvZGQgbnVtYmVyAAAAD051bWJlck11c3RCZU9kZAAAAAAB", - "AAAAAAAAAAAAAAAFaGVsbG8AAAAAAAABAAAAAAAAAAVoZWxsbwAAAAAAABEAAAABAAAAEQ==", - "AAAAAAAAAAAAAAAEd29pZAAAAAAAAAAA", - "AAAAAAAAAAAAAAADdmFsAAAAAAAAAAABAAAAAA==", - "AAAAAAAAAAAAAAAQdTMyX2ZhaWxfb25fZXZlbgAAAAEAAAAAAAAABHUzMl8AAAAEAAAAAQAAA+kAAAAEAAAAAw==", - "AAAAAAAAAAAAAAAEdTMyXwAAAAEAAAAAAAAABHUzMl8AAAAEAAAAAQAAAAQ=", - "AAAAAAAAAAAAAAAEaTMyXwAAAAEAAAAAAAAABGkzMl8AAAAFAAAAAQAAAAU=", - "AAAAAAAAAAAAAAAEaTY0XwAAAAEAAAAAAAAABGk2NF8AAAAHAAAAAQAAAAc=", - "AAAAAAAAACxFeGFtcGxlIGNvbnRyYWN0IG1ldGhvZCB3aGljaCB0YWtlcyBhIHN0cnVjdAAAAApzdHJ1a3RfaGVsAAAAAAABAAAAAAAAAAZzdHJ1a3QAAAAAB9AAAAAEVGVzdAAAAAEAAAPqAAAAEQ==", - "AAAAAAAAAAAAAAAGc3RydWt0AAAAAAABAAAAAAAAAAZzdHJ1a3QAAAAAB9AAAAAEVGVzdAAAAAEAAAfQAAAABFRlc3Q=", - "AAAAAAAAAAAAAAAGc2ltcGxlAAAAAAABAAAAAAAAAAZzaW1wbGUAAAAAB9AAAAAKU2ltcGxlRW51bQAAAAAAAQAAB9AAAAAKU2ltcGxlRW51bQAA", - "AAAAAAAAAAAAAAAHY29tcGxleAAAAAABAAAAAAAAAAdjb21wbGV4AAAAB9AAAAALQ29tcGxleEVudW0AAAAAAQAAB9AAAAALQ29tcGxleEVudW0A", - "AAAAAAAAAAAAAAAIYWRkcmVzc2UAAAABAAAAAAAAAAhhZGRyZXNzZQAAABMAAAABAAAAEw==", - "AAAAAAAAAAAAAAAFYnl0ZXMAAAAAAAABAAAAAAAAAAVieXRlcwAAAAAAAA4AAAABAAAADg==", - "AAAAAAAAAAAAAAAHYnl0ZXNfbgAAAAABAAAAAAAAAAdieXRlc19uAAAAA+4AAAAJAAAAAQAAA+4AAAAJ", - "AAAAAAAAAAAAAAAEY2FyZAAAAAEAAAAAAAAABGNhcmQAAAfQAAAACVJveWFsQ2FyZAAAAAAAAAEAAAfQAAAACVJveWFsQ2FyZAAAAA==", - "AAAAAAAAAAAAAAAHYm9vbGVhbgAAAAABAAAAAAAAAAdib29sZWFuAAAAAAEAAAABAAAAAQ==", - "AAAAAAAAABdOZWdhdGVzIGEgYm9vbGVhbiB2YWx1ZQAAAAADbm90AAAAAAEAAAAAAAAAB2Jvb2xlYW4AAAAAAQAAAAEAAAAB", - "AAAAAAAAAAAAAAAEaTEyOAAAAAEAAAAAAAAABGkxMjgAAAALAAAAAQAAAAs=", - "AAAAAAAAAAAAAAAEdTEyOAAAAAEAAAAAAAAABHUxMjgAAAAKAAAAAQAAAAo=", - "AAAAAAAAAAAAAAAKbXVsdGlfYXJncwAAAAAAAgAAAAAAAAABYQAAAAAAAAQAAAAAAAAAAWIAAAAAAAABAAAAAQAAAAQ=", - "AAAAAAAAAAAAAAADbWFwAAAAAAEAAAAAAAAAA21hcAAAAAPsAAAABAAAAAEAAAABAAAD7AAAAAQAAAAB", - "AAAAAAAAAAAAAAADdmVjAAAAAAEAAAAAAAAAA3ZlYwAAAAPqAAAABAAAAAEAAAPqAAAABA==", - "AAAAAAAAAAAAAAAFdHVwbGUAAAAAAAABAAAAAAAAAAV0dXBsZQAAAAAAA+0AAAACAAAAEQAAAAQAAAABAAAD7QAAAAIAAAARAAAABA==", - "AAAAAAAAAB9FeGFtcGxlIG9mIGFuIG9wdGlvbmFsIGFyZ3VtZW50AAAAAAZvcHRpb24AAAAAAAEAAAAAAAAABm9wdGlvbgAAAAAD6AAAAAQAAAABAAAD6AAAAAQ=", - "AAAAAAAAAAAAAAAEdTI1NgAAAAEAAAAAAAAABHUyNTYAAAAMAAAAAQAAAAw=", - "AAAAAAAAAAAAAAAEaTI1NgAAAAEAAAAAAAAABGkyNTYAAAANAAAAAQAAAA0=", - "AAAAAAAAAAAAAAAGc3RyaW5nAAAAAAABAAAAAAAAAAZzdHJpbmcAAAAAABAAAAABAAAAEA==", - "AAAAAAAAAAAAAAAMdHVwbGVfc3RydWt0AAAAAQAAAAAAAAAMdHVwbGVfc3RydWt0AAAH0AAAAAtUdXBsZVN0cnVjdAAAAAABAAAH0AAAAAtUdXBsZVN0cnVjdAA=" - ]); - } - async hello({ hello }, options = {}) { - return await invoke({ - method: 'hello', - args: this.spec.funcArgsToScVals("hello", { hello }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("hello", xdr); - }, - }); - } - async woid(options = {}) { - return await invoke({ - method: 'woid', - args: this.spec.funcArgsToScVals("woid", {}), - ...options, - ...this.options, - parseResultXdr: () => { }, - }); - } - async val(options = {}) { - return await invoke({ - method: 'val', - args: this.spec.funcArgsToScVals("val", {}), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("val", xdr); - }, - }); - } - async u32FailOnEven({ u32_ }, options = {}) { - try { - return await invoke({ - method: 'u32_fail_on_even', - args: this.spec.funcArgsToScVals("u32_fail_on_even", { u32_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return new Ok(this.spec.funcResToNative("u32_fail_on_even", xdr)); - }, - }); - } - catch (e) { - if (typeof e === 'string') { - let err = parseError(e); - if (err) - return err; - } - throw e; - } - } - async u32({ u32_ }, options = {}) { - return await invoke({ - method: 'u32_', - args: this.spec.funcArgsToScVals("u32_", { u32_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("u32_", xdr); - }, - }); - } - async i32({ i32_ }, options = {}) { - return await invoke({ - method: 'i32_', - args: this.spec.funcArgsToScVals("i32_", { i32_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i32_", xdr); - }, - }); - } - async i64({ i64_ }, options = {}) { - return await invoke({ - method: 'i64_', - args: this.spec.funcArgsToScVals("i64_", { i64_ }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i64_", xdr); - }, - }); - } - /** - * Example contract method which takes a struct - */ - async struktHel({ strukt }, options = {}) { - return await invoke({ - method: 'strukt_hel', - args: this.spec.funcArgsToScVals("strukt_hel", { strukt }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("strukt_hel", xdr); - }, - }); - } - async strukt({ strukt }, options = {}) { - return await invoke({ - method: 'strukt', - args: this.spec.funcArgsToScVals("strukt", { strukt }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("strukt", xdr); - }, - }); - } - async simple({ simple }, options = {}) { - return await invoke({ - method: 'simple', - args: this.spec.funcArgsToScVals("simple", { simple }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("simple", xdr); - }, - }); - } - async complex({ complex }, options = {}) { - return await invoke({ - method: 'complex', - args: this.spec.funcArgsToScVals("complex", { complex }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("complex", xdr); - }, - }); - } - async addresse({ addresse }, options = {}) { - return await invoke({ - method: 'addresse', - args: this.spec.funcArgsToScVals("addresse", { addresse }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("addresse", xdr); - }, - }); - } - async bytes({ bytes }, options = {}) { - return await invoke({ - method: 'bytes', - args: this.spec.funcArgsToScVals("bytes", { bytes }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("bytes", xdr); - }, - }); - } - async bytesN({ bytes_n }, options = {}) { - return await invoke({ - method: 'bytes_n', - args: this.spec.funcArgsToScVals("bytes_n", { bytes_n }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("bytes_n", xdr); - }, - }); - } - async card({ card }, options = {}) { - return await invoke({ - method: 'card', - args: this.spec.funcArgsToScVals("card", { card }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("card", xdr); - }, - }); - } - async boolean({ boolean }, options = {}) { - return await invoke({ - method: 'boolean', - args: this.spec.funcArgsToScVals("boolean", { boolean }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("boolean", xdr); - }, - }); - } - /** - * Negates a boolean value - */ - async not({ boolean }, options = {}) { - return await invoke({ - method: 'not', - args: this.spec.funcArgsToScVals("not", { boolean }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("not", xdr); - }, - }); - } - async i128({ i128 }, options = {}) { - return await invoke({ - method: 'i128', - args: this.spec.funcArgsToScVals("i128", { i128 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i128", xdr); - }, - }); - } - async u128({ u128 }, options = {}) { - return await invoke({ - method: 'u128', - args: this.spec.funcArgsToScVals("u128", { u128 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("u128", xdr); - }, - }); - } - async multiArgs({ a, b }, options = {}) { - return await invoke({ - method: 'multi_args', - args: this.spec.funcArgsToScVals("multi_args", { a, b }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("multi_args", xdr); - }, - }); - } - async map({ map }, options = {}) { - return await invoke({ - method: 'map', - args: this.spec.funcArgsToScVals("map", { map }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("map", xdr); - }, - }); - } - async vec({ vec }, options = {}) { - return await invoke({ - method: 'vec', - args: this.spec.funcArgsToScVals("vec", { vec }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("vec", xdr); - }, - }); - } - async tuple({ tuple }, options = {}) { - return await invoke({ - method: 'tuple', - args: this.spec.funcArgsToScVals("tuple", { tuple }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("tuple", xdr); - }, - }); - } - /** - * Example of an optional argument - */ - async option({ option }, options = {}) { - return await invoke({ - method: 'option', - args: this.spec.funcArgsToScVals("option", { option }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("option", xdr); - }, - }); - } - async u256({ u256 }, options = {}) { - return await invoke({ - method: 'u256', - args: this.spec.funcArgsToScVals("u256", { u256 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("u256", xdr); - }, - }); - } - async i256({ i256 }, options = {}) { - return await invoke({ - method: 'i256', - args: this.spec.funcArgsToScVals("i256", { i256 }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("i256", xdr); - }, - }); - } - async string({ string }, options = {}) { - return await invoke({ - method: 'string', - args: this.spec.funcArgsToScVals("string", { string }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("string", xdr); - }, - }); - } - async tupleStrukt({ tuple_strukt }, options = {}) { - return await invoke({ - method: 'tuple_strukt', - args: this.spec.funcArgsToScVals("tuple_strukt", { tuple_strukt }), - ...options, - ...this.options, - parseResultXdr: (xdr) => { - return this.spec.funcResToNative("tuple_strukt", xdr); - }, - }); - } -} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.d.ts deleted file mode 100644 index 1934a69a6..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as SorobanClient from "soroban-client"; -import { SorobanRpc } from "soroban-client"; -import type { Memo, MemoType, Operation, Transaction, xdr } from "soroban-client"; -import type { ClassOptions, MethodOptions, ResponseTypes, Wallet } from "./method-options.js"; -export declare type Tx = Transaction, Operation[]>; -export declare class NotImplementedError extends Error { -} -declare type Simulation = SorobanRpc.SimulateTransactionResponse; -declare type SendTx = SorobanRpc.SendTransactionResponse; -declare type GetTx = SorobanRpc.GetTransactionResponse; -declare let someRpcResponse: Simulation | SendTx | GetTx; -declare type SomeRpcResponse = typeof someRpcResponse; -declare type InvokeArgs = MethodOptions & ClassOptions & { - method: string; - args?: any[]; - parseResultXdr: (xdr: string | xdr.ScVal) => T; -}; -/** - * Invoke a method on the test_custom_types contract. - * - * Uses Freighter to determine the current user and if necessary sign the transaction. - * - * @returns {T}, by default, the parsed XDR from either the simulation or the full transaction. If `simulateOnly` or `fullRpcResponse` are true, returns either the full simulation or the result of sending/getting the transaction to/from the ledger. - */ -export declare function invoke(args: InvokeArgs): Promise; -/** - * Sign a transaction with Freighter and return the fully-reconstructed - * transaction ready to send with {@link sendTx}. - * - * If you need to construct a transaction yourself rather than using `invoke` - * or one of the exported contract methods, you may want to use this function - * to sign the transaction with Freighter. - */ -export declare function signTx(wallet: Wallet, tx: Tx, networkPassphrase: string): Promise; -/** - * Send a transaction to the Soroban network. - * - * Wait `secondsToWait` seconds for the transaction to complete (default: 10). - * - * If you need to construct or sign a transaction yourself rather than using - * `invoke` or one of the exported contract methods, you may want to use this - * function for its timeout/`secondsToWait` logic, rather than implementing - * your own. - */ -export declare function sendTx(tx: Tx, secondsToWait: number, server: SorobanClient.Server): Promise; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.js deleted file mode 100644 index 2b2830018..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/invoke.js +++ /dev/null @@ -1,147 +0,0 @@ -import * as SorobanClient from "soroban-client"; -import { SorobanRpc } from "soroban-client"; -/** - * Get account details from the Soroban network for the publicKey currently - * selected in Freighter. If not connected to Freighter, return null. - */ -async function getAccount(wallet, server) { - if (!(await wallet.isConnected()) || !(await wallet.isAllowed())) { - return null; - } - const { publicKey } = await wallet.getUserInfo(); - if (!publicKey) { - return null; - } - return await server.getAccount(publicKey); -} -export class NotImplementedError extends Error { -} -// defined this way so typeahead shows full union, not named alias -let someRpcResponse; -export async function invoke({ method, args = [], fee = 100, responseType, parseResultXdr, secondsToWait = 10, rpcUrl, networkPassphrase, contractId, wallet, }) { - wallet = wallet ?? (await import("@stellar/freighter-api")); - let parse = parseResultXdr; - const server = new SorobanClient.Server(rpcUrl, { - allowHttp: rpcUrl.startsWith("http://"), - }); - const walletAccount = await getAccount(wallet, server); - // use a placeholder null account if not yet connected to Freighter so that view calls can still work - const account = walletAccount ?? - new SorobanClient.Account("GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF", "0"); - const contract = new SorobanClient.Contract(contractId); - let tx = new SorobanClient.TransactionBuilder(account, { - fee: fee.toString(10), - networkPassphrase, - }) - .setNetworkPassphrase(networkPassphrase) - .addOperation(contract.call(method, ...args)) - .setTimeout(SorobanClient.TimeoutInfinite) - .build(); - const simulated = await server.simulateTransaction(tx); - if (SorobanRpc.isSimulationError(simulated)) { - throw new Error(simulated.error); - } - else if (responseType === "simulated") { - return simulated; - } - else if (!simulated.result) { - throw new Error(`invalid simulation: no result in ${simulated}`); - } - let authsCount = simulated.result.auth.length; - const writeLength = simulated.transactionData.getReadWrite().length; - const isViewCall = (authsCount === 0) && (writeLength === 0); - if (isViewCall) { - if (responseType === "full") { - return simulated; - } - return parseResultXdr(simulated.result.retval); - } - if (authsCount > 1) { - throw new NotImplementedError("Multiple auths not yet supported"); - } - if (authsCount === 1) { - // TODO: figure out how to fix with new SorobanClient - // const auth = SorobanClient.xdr.SorobanAuthorizationEntry.fromXDR(auths![0]!, 'base64') - // if (auth.addressWithNonce() !== undefined) { - // throw new NotImplementedError( - // `This transaction needs to be signed by ${auth.addressWithNonce() - // }; Not yet supported` - // ) - // } - } - if (!walletAccount) { - throw new Error("Not connected to Freighter"); - } - tx = await signTx(wallet, SorobanClient.assembleTransaction(tx, networkPassphrase, simulated).build(), networkPassphrase); - const raw = await sendTx(tx, secondsToWait, server); - if (responseType === "full") { - return raw; - } - // if `sendTx` awaited the inclusion of the tx in the ledger, it used - // `getTransaction`, which has a `resultXdr` field - if ("resultXdr" in raw) { - const getResult = raw; - if (getResult.status !== SorobanRpc.GetTransactionStatus.SUCCESS) { - console.error('Transaction submission failed! Returning full RPC response.'); - return raw; - } - return parse(raw.resultXdr.result().toXDR("base64")); - } - // otherwise, it returned the result of `sendTransaction` - if ("errorResultXdr" in raw) { - const sendResult = raw; - return parse(sendResult.errorResultXdr); - } - // if neither of these are present, something went wrong - console.error("Don't know how to parse result! Returning full RPC response."); - return raw; -} -/** - * Sign a transaction with Freighter and return the fully-reconstructed - * transaction ready to send with {@link sendTx}. - * - * If you need to construct a transaction yourself rather than using `invoke` - * or one of the exported contract methods, you may want to use this function - * to sign the transaction with Freighter. - */ -export async function signTx(wallet, tx, networkPassphrase) { - const signed = await wallet.signTransaction(tx.toXDR(), { - networkPassphrase, - }); - return SorobanClient.TransactionBuilder.fromXDR(signed, networkPassphrase); -} -/** - * Send a transaction to the Soroban network. - * - * Wait `secondsToWait` seconds for the transaction to complete (default: 10). - * - * If you need to construct or sign a transaction yourself rather than using - * `invoke` or one of the exported contract methods, you may want to use this - * function for its timeout/`secondsToWait` logic, rather than implementing - * your own. - */ -export async function sendTx(tx, secondsToWait, server) { - const sendTransactionResponse = await server.sendTransaction(tx); - if (sendTransactionResponse.status !== "PENDING" || secondsToWait === 0) { - return sendTransactionResponse; - } - let getTransactionResponse = await server.getTransaction(sendTransactionResponse.hash); - const waitUntil = new Date(Date.now() + secondsToWait * 1000).valueOf(); - let waitTime = 1000; - let exponentialFactor = 1.5; - while (Date.now() < waitUntil && - getTransactionResponse.status === SorobanRpc.GetTransactionStatus.NOT_FOUND) { - // Wait a beat - await new Promise((resolve) => setTimeout(resolve, waitTime)); - /// Exponential backoff - waitTime = waitTime * exponentialFactor; - // See if the transaction is complete - getTransactionResponse = await server.getTransaction(sendTransactionResponse.hash); - } - if (getTransactionResponse.status === SorobanRpc.GetTransactionStatus.NOT_FOUND) { - console.error(`Waited ${secondsToWait} seconds for transaction to complete, but it did not. ` + - `Returning anyway. Check the transaction status manually. ` + - `Info: ${JSON.stringify(sendTransactionResponse, null, 2)}`); - } - return getTransactionResponse; -} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.d.ts deleted file mode 100644 index a959d97f2..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -declare let responseTypes: 'simulated' | 'full' | undefined; -export declare type ResponseTypes = typeof responseTypes; -export declare type XDR_BASE64 = string; -export interface Wallet { - isConnected: () => Promise; - isAllowed: () => Promise; - getUserInfo: () => Promise<{ - publicKey?: string; - }>; - signTransaction: (tx: XDR_BASE64, opts?: { - network?: string; - networkPassphrase?: string; - accountToSign?: string; - }) => Promise; -} -export declare type ClassOptions = { - contractId: string; - networkPassphrase: string; - rpcUrl: string; - /** - * A Wallet interface, such as Freighter, that has the methods `isConnected`, `isAllowed`, `getUserInfo`, and `signTransaction`. If not provided, will attempt to import and use Freighter. Example: - * - * @example - * ```ts - * import freighter from "@stellar/freighter-api"; - * import { Contract } from "test_custom_types"; - * const contract = new Contract({ - * …, - * wallet: freighter, - * }) - * ``` - */ - wallet?: Wallet; -}; -export declare type MethodOptions = { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `{RETURN_TYPE}`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; -}; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.js b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.js deleted file mode 100644 index 00ad9d3cf..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/method-options.js +++ /dev/null @@ -1,3 +0,0 @@ -// defined this way so typeahead shows full union, not named alias -let responseTypes; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/package.json b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/package.json deleted file mode 100644 index 1632c2c4d..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/esm/package.json +++ /dev/null @@ -1 +0,0 @@ -{"type": "module"} \ No newline at end of file diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/convert.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/convert.d.ts deleted file mode 100644 index 6db3b88d3..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/convert.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { xdr } from 'soroban-client'; -export declare function strToScVal(base64Xdr: string): xdr.ScVal; -export declare function scValStrToJs(base64Xdr: string): T; -export declare function scValToJs(val: xdr.ScVal): T; -export declare function addressToScVal(addr: string): xdr.ScVal; -export declare function i128ToScVal(i: bigint): xdr.ScVal; -export declare function u128ToScVal(i: bigint): xdr.ScVal; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/index.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/index.d.ts deleted file mode 100644 index afc811097..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/index.d.ts +++ /dev/null @@ -1,660 +0,0 @@ -import * as SorobanClient from 'soroban-client'; -import { ContractSpec, Address } from 'soroban-client'; -import { Buffer } from "buffer"; -import type { ResponseTypes, ClassOptions } from './method-options.js'; -export * from './invoke.js'; -export * from './method-options.js'; -export declare type u32 = number; -export declare type i32 = number; -export declare type u64 = bigint; -export declare type i64 = bigint; -export declare type u128 = bigint; -export declare type i128 = bigint; -export declare type u256 = bigint; -export declare type i256 = bigint; -export declare type Option = T | undefined; -export declare type Typepoint = bigint; -export declare type Duration = bigint; -export { Address }; -export interface Error_ { - message: string; -} -export interface Result { - unwrap(): T; - unwrapErr(): E; - isOk(): boolean; - isErr(): boolean; -} -export declare class Ok implements Result { - readonly value: T; - constructor(value: T); - unwrapErr(): E; - unwrap(): T; - isOk(): boolean; - isErr(): boolean; -} -export declare class Err implements Result { - readonly error: E; - constructor(error: E); - unwrapErr(): E; - unwrap(): never; - isOk(): boolean; - isErr(): boolean; -} -export declare const networks: { - readonly futurenet: { - readonly networkPassphrase: "Test SDF Future Network ; October 2022"; - readonly contractId: "CBYMYMSDF6FBDNCFJCRC7KMO4REYFPOH2U4N7FXI3GJO6YXNCQ43CDSK"; - }; -}; -/** - * This is from the rust doc above the struct Test - */ -export interface Test { - a: u32; - b: boolean; - c: string; -} -export declare type SimpleEnum = { - tag: "First"; - values: void; -} | { - tag: "Second"; - values: void; -} | { - tag: "Third"; - values: void; -}; -export declare enum RoyalCard { - Jack = 11, - Queen = 12, - King = 13 -} -export declare type TupleStruct = readonly [Test, SimpleEnum]; -export declare type ComplexEnum = { - tag: "Struct"; - values: readonly [Test]; -} | { - tag: "Tuple"; - values: readonly [TupleStruct]; -} | { - tag: "Enum"; - values: readonly [SimpleEnum]; -} | { - tag: "Asset"; - values: readonly [Address, i128]; -} | { - tag: "Void"; - values: void; -}; -export declare class Contract { - readonly options: ClassOptions; - spec: ContractSpec; - constructor(options: ClassOptions); - hello({ hello }: { - hello: string; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - woid(options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `void`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - val(options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `any`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u32FailOnEven({ u32_ }: { - u32_: u32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Ok | Err | undefined`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise | (R extends undefined ? Err | Ok : R extends "simulated" ? SorobanClient.SorobanRpc.SimulateTransactionResponse : R extends "full" ? SorobanClient.SorobanRpc.SimulateTransactionResponse | SorobanClient.SorobanRpc.SendTransactionResponse | SorobanClient.SorobanRpc.GetTransactionResponse : Err | Ok)>; - u32({ u32_ }: { - u32_: u32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i32({ i32_ }: { - i32_: i32; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i64({ i64_ }: { - i64_: i64; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i64`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Example contract method which takes a struct - */ - struktHel({ strukt }: { - strukt: Test; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Array`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - strukt({ strukt }: { - strukt: Test; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Test`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - simple({ simple }: { - simple: SimpleEnum; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `SimpleEnum`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - complex({ complex }: { - complex: ComplexEnum; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `ComplexEnum`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - addresse({ addresse }: { - addresse: Address; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Address`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - bytes({ bytes }: { - bytes: Buffer; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Buffer`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - bytesN({ bytes_n }: { - bytes_n: Buffer; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Buffer`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - card({ card }: { - card: RoyalCard; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `RoyalCard`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - boolean({ boolean }: { - boolean: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `boolean`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Negates a boolean value - */ - not({ boolean }: { - boolean: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `boolean`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i128({ i128 }: { - i128: i128; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i128`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u128({ u128 }: { - u128: u128; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u128`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - multiArgs({ a, b }: { - a: u32; - b: boolean; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u32`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - map({ map }: { - map: Map; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Map`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise : R extends "simulated" ? SorobanClient.SorobanRpc.SimulateTransactionResponse : R extends "full" ? SorobanClient.SorobanRpc.SimulateTransactionResponse | SorobanClient.SorobanRpc.SendTransactionResponse | SorobanClient.SorobanRpc.GetTransactionResponse : Map>; - vec({ vec }: { - vec: Array; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Array`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - tuple({ tuple }: { - tuple: readonly [string, u32]; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `readonly [string, u32]`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - /** - * Example of an optional argument - */ - option({ option }: { - option: Option; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `Option`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - u256({ u256 }: { - u256: u256; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `u256`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - i256({ i256 }: { - i256: i256; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `i256`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - string({ string }: { - string: string; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; - tupleStrukt({ tuple_strukt }: { - tuple_strukt: TupleStruct; - }, options?: { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `TupleStruct`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; - }): Promise; -} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/invoke.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/invoke.d.ts deleted file mode 100644 index 1934a69a6..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/invoke.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as SorobanClient from "soroban-client"; -import { SorobanRpc } from "soroban-client"; -import type { Memo, MemoType, Operation, Transaction, xdr } from "soroban-client"; -import type { ClassOptions, MethodOptions, ResponseTypes, Wallet } from "./method-options.js"; -export declare type Tx = Transaction, Operation[]>; -export declare class NotImplementedError extends Error { -} -declare type Simulation = SorobanRpc.SimulateTransactionResponse; -declare type SendTx = SorobanRpc.SendTransactionResponse; -declare type GetTx = SorobanRpc.GetTransactionResponse; -declare let someRpcResponse: Simulation | SendTx | GetTx; -declare type SomeRpcResponse = typeof someRpcResponse; -declare type InvokeArgs = MethodOptions & ClassOptions & { - method: string; - args?: any[]; - parseResultXdr: (xdr: string | xdr.ScVal) => T; -}; -/** - * Invoke a method on the test_custom_types contract. - * - * Uses Freighter to determine the current user and if necessary sign the transaction. - * - * @returns {T}, by default, the parsed XDR from either the simulation or the full transaction. If `simulateOnly` or `fullRpcResponse` are true, returns either the full simulation or the result of sending/getting the transaction to/from the ledger. - */ -export declare function invoke(args: InvokeArgs): Promise; -/** - * Sign a transaction with Freighter and return the fully-reconstructed - * transaction ready to send with {@link sendTx}. - * - * If you need to construct a transaction yourself rather than using `invoke` - * or one of the exported contract methods, you may want to use this function - * to sign the transaction with Freighter. - */ -export declare function signTx(wallet: Wallet, tx: Tx, networkPassphrase: string): Promise; -/** - * Send a transaction to the Soroban network. - * - * Wait `secondsToWait` seconds for the transaction to complete (default: 10). - * - * If you need to construct or sign a transaction yourself rather than using - * `invoke` or one of the exported contract methods, you may want to use this - * function for its timeout/`secondsToWait` logic, rather than implementing - * your own. - */ -export declare function sendTx(tx: Tx, secondsToWait: number, server: SorobanClient.Server): Promise; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/method-options.d.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/method-options.d.ts deleted file mode 100644 index a959d97f2..000000000 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/dist/types/method-options.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -declare let responseTypes: 'simulated' | 'full' | undefined; -export declare type ResponseTypes = typeof responseTypes; -export declare type XDR_BASE64 = string; -export interface Wallet { - isConnected: () => Promise; - isAllowed: () => Promise; - getUserInfo: () => Promise<{ - publicKey?: string; - }>; - signTransaction: (tx: XDR_BASE64, opts?: { - network?: string; - networkPassphrase?: string; - accountToSign?: string; - }) => Promise; -} -export declare type ClassOptions = { - contractId: string; - networkPassphrase: string; - rpcUrl: string; - /** - * A Wallet interface, such as Freighter, that has the methods `isConnected`, `isAllowed`, `getUserInfo`, and `signTransaction`. If not provided, will attempt to import and use Freighter. Example: - * - * @example - * ```ts - * import freighter from "@stellar/freighter-api"; - * import { Contract } from "test_custom_types"; - * const contract = new Contract({ - * …, - * wallet: freighter, - * }) - * ``` - */ - wallet?: Wallet; -}; -export declare type MethodOptions = { - /** - * The fee to pay for the transaction. Default: 100. - */ - fee?: number; - /** - * What type of response to return. - * - * - `undefined`, the default, parses the returned XDR as `{RETURN_TYPE}`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. - * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. - * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. - */ - responseType?: R; - /** - * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. - */ - secondsToWait?: number; -}; -export {}; diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/package-lock.json b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/package-lock.json index d2b02b5d1..ea6452d89 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/package-lock.json +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/package-lock.json @@ -1,7 +1,7 @@ { "name": "test_custom_types", "version": "0.0.0", - "lockfileVersion": 2, + "lockfileVersion": 3, "requires": true, "packages": { "": { @@ -25,7 +25,7 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.0", @@ -35,8 +35,7 @@ }, "node_modules/base32.js": { "version": "0.1.0", - "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", - "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==", + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -61,8 +60,7 @@ }, "node_modules/bignumber.js": { "version": "9.1.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", - "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "license": "MIT", "engines": { "node": "*" } @@ -107,7 +105,7 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", + "version": "1.15.3", "funding": [ { "type": "individual", @@ -156,13 +154,11 @@ }, "node_modules/inherits": { "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "license": "ISC" }, "node_modules/js-xdr": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-3.0.0.tgz", - "integrity": "sha512-tSt6UKJ2L7t+yaQURGkHo9kop9qnVbChTlCu62zNiDbDZQoZb/YjUj2iFJ3lgelhfg9p5bhO2o/QX+g36TPsSQ==" + "license": "Apache-2.0" }, "node_modules/mime-db": { "version": "1.52.0", @@ -183,8 +179,7 @@ }, "node_modules/node-gyp-build": { "version": "4.6.1", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz", - "integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==", + "license": "MIT", "optional": true, "bin": { "node-gyp-build": "bin.js", @@ -198,8 +193,6 @@ }, "node_modules/safe-buffer": { "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "funding": [ { "type": "github", @@ -213,12 +206,12 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/sha.js": { "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "license": "(MIT AND BSD-3-Clause)", "dependencies": { "inherits": "^2.0.1", "safe-buffer": "^5.0.1" @@ -229,9 +222,8 @@ }, "node_modules/sodium-native": { "version": "4.0.4", - "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.0.4.tgz", - "integrity": "sha512-faqOKw4WQKK7r/ybn6Lqo1F9+L5T6NlBJJYvpxbZPetpWylUVqz449mvlwIBKBqxEHbWakWuOlUt8J3Qpc4sWw==", "hasInstallScript": true, + "license": "MIT", "optional": true, "dependencies": { "node-gyp-build": "^4.6.0" @@ -239,8 +231,7 @@ }, "node_modules/soroban-client": { "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-1.0.0-beta.2.tgz", - "integrity": "sha512-v5h3yvef7HkUD3H26w33NUEgRXcPiOSDWEsVzMloaxsprs3N002tXJHvFF+Uw1eYt50Uk6bvqBgvkLwX10VENw==", + "license": "Apache-2.0", "dependencies": { "axios": "^1.4.0", "bignumber.js": "^9.1.1", @@ -251,8 +242,7 @@ }, "node_modules/stellar-base": { "version": "10.0.0-beta.1", - "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-beta.1.tgz", - "integrity": "sha512-zXC5AsbUsLi57JruyeIMv23s3iUxq/P2ZFrSJ+FerLIZjSAjY8EDs4zwY4LCuu7swUu46Lm8GK6sqxUZCPekHw==", + "license": "Apache-2.0", "dependencies": { "base32.js": "^0.1.0", "bignumber.js": "^9.1.2", @@ -267,8 +257,7 @@ }, "node_modules/tweetnacl": { "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + "license": "Unlicense" }, "node_modules/typescript": { "version": "5.1.6", @@ -286,153 +275,5 @@ "version": "1.19.11", "license": "MIT" } - }, - "dependencies": { - "@stellar/freighter-api": { - "version": "1.5.1" - }, - "asynckit": { - "version": "0.4.0" - }, - "axios": { - "version": "1.5.0", - "requires": { - "follow-redirects": "^1.15.0", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" - } - }, - "base32.js": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", - "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==" - }, - "base64-js": { - "version": "1.5.1" - }, - "bignumber.js": { - "version": "9.1.2", - "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", - "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==" - }, - "buffer": { - "version": "6.0.3", - "requires": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "combined-stream": { - "version": "1.0.8", - "requires": { - "delayed-stream": "~1.0.0" - } - }, - "delayed-stream": { - "version": "1.0.0" - }, - "follow-redirects": { - "version": "1.15.2" - }, - "form-data": { - "version": "4.0.0", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, - "ieee754": { - "version": "1.2.1" - }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" - }, - "js-xdr": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-3.0.0.tgz", - "integrity": "sha512-tSt6UKJ2L7t+yaQURGkHo9kop9qnVbChTlCu62zNiDbDZQoZb/YjUj2iFJ3lgelhfg9p5bhO2o/QX+g36TPsSQ==" - }, - "mime-db": { - "version": "1.52.0" - }, - "mime-types": { - "version": "2.1.35", - "requires": { - "mime-db": "1.52.0" - } - }, - "node-gyp-build": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz", - "integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==", - "optional": true - }, - "proxy-from-env": { - "version": "1.1.0" - }, - "safe-buffer": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" - }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "requires": { - "inherits": "^2.0.1", - "safe-buffer": "^5.0.1" - } - }, - "sodium-native": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.0.4.tgz", - "integrity": "sha512-faqOKw4WQKK7r/ybn6Lqo1F9+L5T6NlBJJYvpxbZPetpWylUVqz449mvlwIBKBqxEHbWakWuOlUt8J3Qpc4sWw==", - "optional": true, - "requires": { - "node-gyp-build": "^4.6.0" - } - }, - "soroban-client": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-1.0.0-beta.2.tgz", - "integrity": "sha512-v5h3yvef7HkUD3H26w33NUEgRXcPiOSDWEsVzMloaxsprs3N002tXJHvFF+Uw1eYt50Uk6bvqBgvkLwX10VENw==", - "requires": { - "axios": "^1.4.0", - "bignumber.js": "^9.1.1", - "buffer": "^6.0.3", - "stellar-base": "v10.0.0-beta.1", - "urijs": "^1.19.1" - } - }, - "stellar-base": { - "version": "10.0.0-beta.1", - "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-beta.1.tgz", - "integrity": "sha512-zXC5AsbUsLi57JruyeIMv23s3iUxq/P2ZFrSJ+FerLIZjSAjY8EDs4zwY4LCuu7swUu46Lm8GK6sqxUZCPekHw==", - "requires": { - "base32.js": "^0.1.0", - "bignumber.js": "^9.1.2", - "buffer": "^6.0.3", - "js-xdr": "^3.0.0", - "sha.js": "^2.3.6", - "sodium-native": "^4.0.1", - "tweetnacl": "^1.0.3" - } - }, - "tweetnacl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" - }, - "typescript": { - "version": "5.1.6", - "dev": true - }, - "urijs": { - "version": "1.19.11" - } } } diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/convert.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/convert.ts index ec3087c11..12d7044aa 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/convert.ts +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/convert.ts @@ -51,13 +51,13 @@ export function scValToJs(val: xdr.ScVal): T { } case xdr.ScValType.scvVec(): { type Element = ElementType; - return val.vec().map(v => scValToJs(v)) as unknown as T; + return val.vec()!.map(v => scValToJs(v)) as unknown as T; } case xdr.ScValType.scvMap(): { type Key = KeyType; type Value = ValueType; let res: any = {}; - val.map().forEach((e) => { + val.map()!.forEach((e) => { let key = scValToJs(e.key()); let value; let v: xdr.ScVal = e.val(); @@ -65,7 +65,7 @@ export function scValToJs(val: xdr.ScVal): T { switch (v?.switch()) { case xdr.ScValType.scvMap(): { let inner_map = new Map() as Map; - v.map().forEach((e) => { + v.map()!.forEach((e) => { let key = scValToJs(e.key()); let value = scValToJs(e.val()); inner_map.set(key, value); @@ -109,4 +109,4 @@ export function i128ToScVal(i: bigint): xdr.ScVal { export function u128ToScVal(i: bigint): xdr.ScVal { return new ScInt(i).toU128(); -} \ No newline at end of file +} diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts index 5cce69fe0..d0e4e0349 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/index.ts @@ -97,8 +97,8 @@ export const networks = { } as const /** - * This is from the rust doc above the struct Test - */ + * This is from the rust doc above the struct Test + */ export interface Test { a: u32; b: boolean; @@ -114,7 +114,7 @@ export enum RoyalCard { } export type TupleStruct = readonly [Test, SimpleEnum]; -export type ComplexEnum = {tag: "Struct", values: readonly [Test]} | {tag: "Tuple", values: readonly [TupleStruct]} | {tag: "Enum", values: readonly [SimpleEnum]} | {tag: "Asset", values: readonly [Address, i128]} | {tag: "Void", values: void}; +export type ComplexEnum = {tag: "Struct", values: readonly [Test]} | {tag: "Tuple", values: readonly [TupleStruct]} | {tag: "Enum", values: readonly [SimpleEnum]} | {tag: "Asset", values: readonly [string, i128]} | {tag: "Void", values: void}; const Errors = { 1: {message:"Please provide an odd number"} @@ -160,7 +160,7 @@ export class Contract { "AAAAAAAAAAAAAAAMdHVwbGVfc3RydWt0AAAAAQAAAAAAAAAMdHVwbGVfc3RydWt0AAAH0AAAAAtUdXBsZVN0cnVjdAAAAAABAAAH0AAAAAtUdXBsZVN0cnVjdAA=" ]); } - async hello({hello}: {hello: string}, options: { + hello = async ({hello}: {hello: string}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -177,7 +177,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'hello', args: this.spec.funcArgsToScVals("hello", {hello}), @@ -190,7 +190,7 @@ export class Contract { } - async woid(options: { + woid = async (options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -207,7 +207,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'woid', args: this.spec.funcArgsToScVals("woid", {}), @@ -218,7 +218,7 @@ export class Contract { } - async val(options: { + val = async (options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -235,7 +235,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'val', args: this.spec.funcArgsToScVals("val", {}), @@ -248,7 +248,7 @@ export class Contract { } - async u32FailOnEven({u32_}: {u32_: u32}, options: { + u32FailOnEven = async ({u32_}: {u32_: u32}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -265,7 +265,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { try { return await invoke({ method: 'u32_fail_on_even', @@ -277,16 +277,14 @@ export class Contract { }, }); } catch (e) { - if (typeof e === 'string') { - let err = parseError(e); - if (err) return err; - } + let err = parseError(e.toString()); + if (err) return err; throw e; } } - async u32({u32_}: {u32_: u32}, options: { + u32 = async ({u32_}: {u32_: u32}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -303,7 +301,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'u32_', args: this.spec.funcArgsToScVals("u32_", {u32_}), @@ -316,7 +314,7 @@ export class Contract { } - async i32({i32_}: {i32_: i32}, options: { + i32 = async ({i32_}: {i32_: i32}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -333,7 +331,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'i32_', args: this.spec.funcArgsToScVals("i32_", {i32_}), @@ -346,7 +344,7 @@ export class Contract { } - async i64({i64_}: {i64_: i64}, options: { + i64 = async ({i64_}: {i64_: i64}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -363,7 +361,7 @@ export class Contract { * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'i64_', args: this.spec.funcArgsToScVals("i64_", {i64_}), @@ -377,9 +375,9 @@ export class Contract { /** - * Example contract method which takes a struct - */ -async struktHel({strukt}: {strukt: Test}, options: { + * Example contract method which takes a struct + */ +struktHel = async ({strukt}: {strukt: Test}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -396,7 +394,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'strukt_hel', args: this.spec.funcArgsToScVals("strukt_hel", {strukt}), @@ -409,7 +407,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async strukt({strukt}: {strukt: Test}, options: { + strukt = async ({strukt}: {strukt: Test}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -426,7 +424,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'strukt', args: this.spec.funcArgsToScVals("strukt", {strukt}), @@ -439,7 +437,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async simple({simple}: {simple: SimpleEnum}, options: { + simple = async ({simple}: {simple: SimpleEnum}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -456,7 +454,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'simple', args: this.spec.funcArgsToScVals("simple", {simple}), @@ -469,7 +467,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async complex({complex}: {complex: ComplexEnum}, options: { + complex = async ({complex}: {complex: ComplexEnum}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -486,7 +484,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'complex', args: this.spec.funcArgsToScVals("complex", {complex}), @@ -499,7 +497,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async addresse({addresse}: {addresse: Address}, options: { + addresse = async ({addresse}: {addresse: string}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -507,7 +505,7 @@ async struktHel({strukt}: {strukt: Test}, o /** * What type of response to return. * - * - `undefined`, the default, parses the returned XDR as `Address`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. + * - `undefined`, the default, parses the returned XDR as `string`. Runs preflight, checks to see if auth/signing is required, and sends the transaction if so. If there's no error and `secondsToWait` is positive, awaits the finalized transaction. * - `'simulated'` will only simulate/preflight the transaction, even if it's a change/set method that requires auth/signing. Returns full preflight info. * - `'full'` return the full RPC response, meaning either 1. the preflight info, if it's a view/read method that doesn't require auth/signing, or 2. the `sendTransaction` response, if there's a problem with sending the transaction or if you set `secondsToWait` to 0, or 3. the `getTransaction` response, if it's a change method with no `sendTransaction` errors and a positive `secondsToWait`. */ @@ -516,20 +514,20 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'addresse', - args: this.spec.funcArgsToScVals("addresse", {addresse}), + args: this.spec.funcArgsToScVals("addresse", {addresse: new Address(addresse)}), ...options, ...this.options, - parseResultXdr: (xdr): Address => { + parseResultXdr: (xdr): string => { return this.spec.funcResToNative("addresse", xdr); }, }); } - async bytes({bytes}: {bytes: Buffer}, options: { + bytes = async ({bytes}: {bytes: Buffer}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -546,7 +544,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'bytes', args: this.spec.funcArgsToScVals("bytes", {bytes}), @@ -559,7 +557,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async bytesN({bytes_n}: {bytes_n: Buffer}, options: { + bytesN = async ({bytes_n}: {bytes_n: Buffer}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -576,7 +574,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'bytes_n', args: this.spec.funcArgsToScVals("bytes_n", {bytes_n}), @@ -589,7 +587,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async card({card}: {card: RoyalCard}, options: { + card = async ({card}: {card: RoyalCard}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -606,7 +604,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'card', args: this.spec.funcArgsToScVals("card", {card}), @@ -619,7 +617,7 @@ async struktHel({strukt}: {strukt: Test}, o } - async boolean({boolean}: {boolean: boolean}, options: { + boolean = async ({boolean}: {boolean: boolean}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -636,7 +634,7 @@ async struktHel({strukt}: {strukt: Test}, o * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'boolean', args: this.spec.funcArgsToScVals("boolean", {boolean}), @@ -650,9 +648,9 @@ async struktHel({strukt}: {strukt: Test}, o /** - * Negates a boolean value - */ -async not({boolean}: {boolean: boolean}, options: { + * Negates a boolean value + */ +not = async ({boolean}: {boolean: boolean}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -669,7 +667,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'not', args: this.spec.funcArgsToScVals("not", {boolean}), @@ -682,7 +680,7 @@ async not({boolean}: {boolean: boolean}, op } - async i128({i128}: {i128: i128}, options: { + i128 = async ({i128}: {i128: i128}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -699,7 +697,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'i128', args: this.spec.funcArgsToScVals("i128", {i128}), @@ -712,7 +710,7 @@ async not({boolean}: {boolean: boolean}, op } - async u128({u128}: {u128: u128}, options: { + u128 = async ({u128}: {u128: u128}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -729,7 +727,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'u128', args: this.spec.funcArgsToScVals("u128", {u128}), @@ -742,7 +740,7 @@ async not({boolean}: {boolean: boolean}, op } - async multiArgs({a, b}: {a: u32, b: boolean}, options: { + multiArgs = async ({a, b}: {a: u32, b: boolean}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -759,7 +757,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'multi_args', args: this.spec.funcArgsToScVals("multi_args", {a, b}), @@ -772,7 +770,7 @@ async not({boolean}: {boolean: boolean}, op } - async map({map}: {map: Map}, options: { + map = async ({map}: {map: Map}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -789,7 +787,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'map', args: this.spec.funcArgsToScVals("map", {map}), @@ -802,7 +800,7 @@ async not({boolean}: {boolean: boolean}, op } - async vec({vec}: {vec: Array}, options: { + vec = async ({vec}: {vec: Array}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -819,7 +817,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'vec', args: this.spec.funcArgsToScVals("vec", {vec}), @@ -832,7 +830,7 @@ async not({boolean}: {boolean: boolean}, op } - async tuple({tuple}: {tuple: readonly [string, u32]}, options: { + tuple = async ({tuple}: {tuple: readonly [string, u32]}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -849,7 +847,7 @@ async not({boolean}: {boolean: boolean}, op * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'tuple', args: this.spec.funcArgsToScVals("tuple", {tuple}), @@ -863,9 +861,9 @@ async not({boolean}: {boolean: boolean}, op /** - * Example of an optional argument - */ -async option({option}: {option: Option}, options: { + * Example of an optional argument + */ +option = async ({option}: {option: Option}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -882,7 +880,7 @@ async option({option}: {option: Option * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'option', args: this.spec.funcArgsToScVals("option", {option}), @@ -895,7 +893,7 @@ async option({option}: {option: Option } - async u256({u256}: {u256: u256}, options: { + u256 = async ({u256}: {u256: u256}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -912,7 +910,7 @@ async option({option}: {option: Option * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'u256', args: this.spec.funcArgsToScVals("u256", {u256}), @@ -925,7 +923,7 @@ async option({option}: {option: Option } - async i256({i256}: {i256: i256}, options: { + i256 = async ({i256}: {i256: i256}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -942,7 +940,7 @@ async option({option}: {option: Option * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'i256', args: this.spec.funcArgsToScVals("i256", {i256}), @@ -955,7 +953,7 @@ async option({option}: {option: Option } - async string({string}: {string: string}, options: { + string = async ({string}: {string: string}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -972,7 +970,7 @@ async option({option}: {option: Option * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'string', args: this.spec.funcArgsToScVals("string", {string}), @@ -985,7 +983,7 @@ async option({option}: {option: Option } - async tupleStrukt({tuple_strukt}: {tuple_strukt: TupleStruct}, options: { + tupleStrukt = async ({tuple_strukt}: {tuple_strukt: TupleStruct}, options: { /** * The fee to pay for the transaction. Default: 100. */ @@ -1002,7 +1000,7 @@ async option({option}: {option: Option * If the simulation shows that this invocation requires auth/signing, `invoke` will wait `secondsToWait` seconds for the transaction to complete before giving up and returning the incomplete {@link SorobanClient.SorobanRpc.GetTransactionResponse} results (or attempting to parse their probably-missing XDR with `parseResultXdr`, depending on `responseType`). Set this to `0` to skip waiting altogether, which will return you {@link SorobanClient.SorobanRpc.SendTransactionResponse} more quickly, before the transaction has time to be included in the ledger. Default: 10. */ secondsToWait?: number - } = {}) { + } = {}) => { return await invoke({ method: 'tuple_strukt', args: this.spec.funcArgsToScVals("tuple_strukt", {tuple_strukt}), diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/invoke.ts b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/invoke.ts index 93f823f1f..d69166ce1 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/invoke.ts +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/src/invoke.ts @@ -103,7 +103,6 @@ export async function invoke({ fee: fee.toString(10), networkPassphrase, }) - .setNetworkPassphrase(networkPassphrase) .addOperation(contract.call(method, ...args)) .setTimeout(SorobanClient.TimeoutInfinite) .build(); @@ -159,22 +158,11 @@ export async function invoke({ } // if `sendTx` awaited the inclusion of the tx in the ledger, it used - // `getTransaction`, which has a `resultXdr` field - if ("resultXdr" in raw) { - const getResult = raw as SorobanRpc.GetTransactionResponse; - if (getResult.status !== SorobanRpc.GetTransactionStatus.SUCCESS) { - console.error('Transaction submission failed! Returning full RPC response.'); - return raw; - } - - return parse(raw.resultXdr.result().toXDR("base64")); - } + // `getTransaction`, which has a `returnValue` field + if ("returnValue" in raw) return parse(raw.returnValue!); // otherwise, it returned the result of `sendTransaction` - if ("errorResultXdr" in raw) { - const sendResult = raw as SorobanRpc.SendTransactionResponse; - return parse(sendResult.errorResultXdr); - } + if ("errorResultXdr" in raw) return parse(raw.errorResultXdr!); // if neither of these are present, something went wrong console.error("Don't know how to parse result! Returning full RPC response."); diff --git a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/tsconfig.json b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/tsconfig.json index 12cd92abf..efd4c6193 100644 --- a/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/tsconfig.json +++ b/cmd/crates/soroban-spec-typescript/fixtures/test_custom_types/tsconfig.json @@ -71,7 +71,7 @@ /* Type Checking */ // "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ @@ -95,4 +95,4 @@ "include": [ "src/*" ] -} \ No newline at end of file +} diff --git a/cmd/crates/soroban-spec-typescript/src/boilerplate.rs b/cmd/crates/soroban-spec-typescript/src/boilerplate.rs index 20d517a2a..ae14ae476 100644 --- a/cmd/crates/soroban-spec-typescript/src/boilerplate.rs +++ b/cmd/crates/soroban-spec-typescript/src/boilerplate.rs @@ -12,8 +12,9 @@ use super::generate; static PROJECT_DIR: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/src/project_template"); +const NETWORK_PASSPHRASE_TESTNET: &str = "Test SDF Network ; September 2015"; const NETWORK_PASSPHRASE_FUTURENET: &str = "Test SDF Future Network ; October 2022"; -const NETWORK_PASSPHRASE_LOCALNET: &str = "Standalone Network ; February 2017"; +const NETWORK_PASSPHRASE_STANDALONE: &str = "Standalone Network ; February 2017"; pub struct Project(PathBuf); @@ -110,12 +111,11 @@ impl Project { } fn format_networks_object(contract_id: &str, network_passphrase: &str) -> String { - let network = if network_passphrase == NETWORK_PASSPHRASE_FUTURENET { - "futurenet" - } else if network_passphrase == NETWORK_PASSPHRASE_LOCALNET { - "localnet" - } else { - "unknown" + let network = match network_passphrase { + NETWORK_PASSPHRASE_TESTNET => "testnet", + NETWORK_PASSPHRASE_FUTURENET => "futurenet", + NETWORK_PASSPHRASE_STANDALONE => "standalone", + _ => "unknown", }; format!( r#"export const networks = {{ diff --git a/cmd/crates/soroban-spec-typescript/src/lib.rs b/cmd/crates/soroban-spec-typescript/src/lib.rs index 7f2ea761d..5e8f8f210 100644 --- a/cmd/crates/soroban-spec-typescript/src/lib.rs +++ b/cmd/crates/soroban-spec-typescript/src/lib.rs @@ -103,8 +103,8 @@ fn doc_to_ts_doc(doc: &str) -> String { let doc = doc.split('\n').join("\n * "); format!( r#"/** - * {doc} - */ + * {doc} + */ "#, ) } @@ -202,7 +202,9 @@ pub fn entry_to_ts(entry: &Entry) -> String { }; let js_name = jsify_name(name); let options = method_options(&return_type); - let args = format!("args: this.spec.funcArgsToScVals(\"{name}\", {{{input_vals}}}),"); + let parsed_scvals = inputs.iter().map(parse_arg_to_scval).join(", "); + let args = + format!("args: this.spec.funcArgsToScVals(\"{name}\", {{{parsed_scvals}}}),"); let mut body = format!( r#"return await invoke({{ method: '{name}', @@ -217,16 +219,14 @@ pub fn entry_to_ts(entry: &Entry) -> String { r#"try {{ {body} }} catch (e) {{ - if (typeof e === 'string') {{ - let err = parseError(e); - if (err) return err; - }} + let err = parseError(e.toString()); + if (err) return err; throw e; }}"# ); } format!( - r#"{ts_doc}async {js_name}({input}options: {options} = {{}}) {{ + r#"{ts_doc}{js_name} = async ({input}options: {options} = {{}}) => {{ {body} }} "# @@ -319,6 +319,14 @@ pub fn func_input_to_arg_name(input: &types::FunctionInput) -> String { name.to_string() } +pub fn parse_arg_to_scval(input: &types::FunctionInput) -> String { + let types::FunctionInput { name, value, .. } = input; + match value { + types::Type::Address => format!("{name}: new Address({name})"), + _ => name.to_string(), + } +} + pub fn type_to_ts(value: &types::Type) -> String { match value { types::Type::U64 => "u64".to_owned(), @@ -349,7 +357,7 @@ pub fn type_to_ts(value: &types::Type) -> String { // ahalabs have added in the bindings, so.. maybe rename that? types::Type::Val => "any".to_owned(), types::Type::Error { .. } => "Error_".to_owned(), - types::Type::Address => "Address".to_string(), + types::Type::Address => "string".to_string(), types::Type::Bytes | types::Type::BytesN { .. } => "Buffer".to_string(), types::Type::Void => "void".to_owned(), types::Type::U256 => "u256".to_string(), diff --git a/cmd/crates/soroban-spec-typescript/src/project_template/src/convert.ts b/cmd/crates/soroban-spec-typescript/src/project_template/src/convert.ts index ec3087c11..12d7044aa 100644 --- a/cmd/crates/soroban-spec-typescript/src/project_template/src/convert.ts +++ b/cmd/crates/soroban-spec-typescript/src/project_template/src/convert.ts @@ -51,13 +51,13 @@ export function scValToJs(val: xdr.ScVal): T { } case xdr.ScValType.scvVec(): { type Element = ElementType; - return val.vec().map(v => scValToJs(v)) as unknown as T; + return val.vec()!.map(v => scValToJs(v)) as unknown as T; } case xdr.ScValType.scvMap(): { type Key = KeyType; type Value = ValueType; let res: any = {}; - val.map().forEach((e) => { + val.map()!.forEach((e) => { let key = scValToJs(e.key()); let value; let v: xdr.ScVal = e.val(); @@ -65,7 +65,7 @@ export function scValToJs(val: xdr.ScVal): T { switch (v?.switch()) { case xdr.ScValType.scvMap(): { let inner_map = new Map() as Map; - v.map().forEach((e) => { + v.map()!.forEach((e) => { let key = scValToJs(e.key()); let value = scValToJs(e.val()); inner_map.set(key, value); @@ -109,4 +109,4 @@ export function i128ToScVal(i: bigint): xdr.ScVal { export function u128ToScVal(i: bigint): xdr.ScVal { return new ScInt(i).toU128(); -} \ No newline at end of file +} diff --git a/cmd/crates/soroban-spec-typescript/src/project_template/src/invoke.ts b/cmd/crates/soroban-spec-typescript/src/project_template/src/invoke.ts index 5bcd7d80f..d69166ce1 100644 --- a/cmd/crates/soroban-spec-typescript/src/project_template/src/invoke.ts +++ b/cmd/crates/soroban-spec-typescript/src/project_template/src/invoke.ts @@ -158,22 +158,11 @@ export async function invoke({ } // if `sendTx` awaited the inclusion of the tx in the ledger, it used - // `getTransaction`, which has a `resultXdr` field - if ("resultXdr" in raw) { - const getResult = raw as SorobanRpc.GetTransactionResponse; - if (getResult.status !== SorobanRpc.GetTransactionStatus.SUCCESS) { - console.error('Transaction submission failed! Returning full RPC response.'); - return raw; - } - - return parse(raw.resultXdr.result().toXDR("base64")); - } + // `getTransaction`, which has a `returnValue` field + if ("returnValue" in raw) return parse(raw.returnValue!); // otherwise, it returned the result of `sendTransaction` - if ("errorResultXdr" in raw) { - const sendResult = raw as SorobanRpc.SendTransactionResponse; - return parse(sendResult.errorResultXdr); - } + if ("errorResultXdr" in raw) return parse(raw.errorResultXdr!); // if neither of these are present, something went wrong console.error("Don't know how to parse result! Returning full RPC response."); diff --git a/cmd/crates/soroban-spec-typescript/src/project_template/tsconfig.json b/cmd/crates/soroban-spec-typescript/src/project_template/tsconfig.json index 12cd92abf..efd4c6193 100644 --- a/cmd/crates/soroban-spec-typescript/src/project_template/tsconfig.json +++ b/cmd/crates/soroban-spec-typescript/src/project_template/tsconfig.json @@ -71,7 +71,7 @@ /* Type Checking */ // "strict": true, /* Enable all strict type-checking options. */ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ @@ -95,4 +95,4 @@ "include": [ "src/*" ] -} \ No newline at end of file +} diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/.env b/cmd/crates/soroban-spec-typescript/ts-tests/.env new file mode 100644 index 000000000..e69de29bb diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/.gitignore b/cmd/crates/soroban-spec-typescript/ts-tests/.gitignore index a9cc241d8..dda1cd312 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/.gitignore +++ b/cmd/crates/soroban-spec-typescript/ts-tests/.gitignore @@ -1,3 +1,4 @@ build node_modules -yarn.lock \ No newline at end of file +yarn.lock +contract-id-*.txt diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/.nvmrc b/cmd/crates/soroban-spec-typescript/ts-tests/.nvmrc new file mode 100644 index 000000000..03db17dcc --- /dev/null +++ b/cmd/crates/soroban-spec-typescript/ts-tests/.nvmrc @@ -0,0 +1 @@ +v20.6.0 diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json b/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json index 954928b09..20622f5c9 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/package-lock.json @@ -4,11 +4,17 @@ "requires": true, "packages": { "": { + "hasInstallScript": true, "devDependencies": { "@ava/typescript": "^4.1.0", "@types/node": "^20.4.9", "ava": "^5.3.1", + "soroban-client": "1.0.0-beta.2", "typescript": "^5.1.6" + }, + "engines": { + "node": ">=20.0.0", + "npm": ">=9.8.1" } }, "node_modules/@ava/typescript": { @@ -60,9 +66,9 @@ } }, "node_modules/@types/node": { - "version": "20.4.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.4.9.tgz", - "integrity": "sha512-8e2HYcg7ohnTUbHk8focoklEQYvemQmu9M/f43DZVx43kHn0tE3BY/6gSDxS7k0SprtS0NHvj+L80cGLnoOUcQ==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "dev": true }, "node_modules/acorn": { @@ -178,6 +184,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "dev": true + }, "node_modules/ava": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/ava/-/ava-5.3.1.tgz", @@ -243,6 +255,55 @@ } } }, + "node_modules/axios": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.5.0.tgz", + "integrity": "sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ==", + "dev": true, + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/base32.js": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/base32.js/-/base32.js-0.1.0.tgz", + "integrity": "sha512-n3TkB02ixgBOhTvANakDb4xaMXnYUVkNoRFJjQflcqMQhyEKxEHdj3E6N8t8sUQ0mjH/3/JxzlXuz3ul/J90pQ==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bignumber.js": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.1.2.tgz", + "integrity": "sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==", + "dev": true, + "engines": { + "node": "*" + } + }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -270,10 +331,34 @@ "node": ">=8" } }, + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/callsites": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/callsites/-/callsites-4.0.0.tgz", - "integrity": "sha512-y3jRROutgpKdz5vzEhWM34TidDU8vkJppF8dszITeb1PQmSqV3DTxyV8G/lyO/DNvtE1YTedehmw9MPZsCBHxQ==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-4.1.0.tgz", + "integrity": "sha512-aBMbD1Xxay75ViYezwT40aQONfr+pSXTHwNKvIXhXD6+LY3F1dLIcceoC5OZKBVHbXcysz1hL9D2w0JJIMXpUw==", "dev": true, "engines": { "node": ">=12.20" @@ -494,6 +579,18 @@ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/common-path-prefix": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/common-path-prefix/-/common-path-prefix-3.0.0.tgz", @@ -589,6 +686,15 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", @@ -691,12 +797,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/execa/node_modules/signal-exit": { - "version": "3.0.7", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", - "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true - }, "node_modules/fast-diff": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", @@ -772,10 +872,44 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/follow-redirects": { + "version": "1.15.2", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, "optional": true, @@ -847,6 +981,26 @@ "node": ">=14.18.0" } }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/ignore": { "version": "5.2.4", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", @@ -886,6 +1040,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, "node_modules/irregular-plurals": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/irregular-plurals/-/irregular-plurals-3.5.0.tgz", @@ -1009,6 +1169,12 @@ "node": ">= 0.8" } }, + "node_modules/js-xdr": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/js-xdr/-/js-xdr-3.0.0.tgz", + "integrity": "sha512-tSt6UKJ2L7t+yaQURGkHo9kop9qnVbChTlCu62zNiDbDZQoZb/YjUj2iFJ3lgelhfg9p5bhO2o/QX+g36TPsSQ==", + "dev": true + }, "node_modules/js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", @@ -1150,6 +1316,27 @@ "node": ">=8.6" } }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-4.0.0.tgz", @@ -1168,6 +1355,18 @@ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, + "node_modules/node-gyp-build": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.1.tgz", + "integrity": "sha512-24vnklJmyRS8ViBNI8KbtK/r/DmXQMRiOMXTNz2nrTnAYUwjmEEbnnpB/+kt+yWRv73bPsSPRFddrcIbAxSiMQ==", + "dev": true, + "optional": true, + "bin": { + "node-gyp-build": "bin.js", + "node-gyp-build-optional": "optional.js", + "node-gyp-build-test": "build-test.js" + } + }, "node_modules/nofilter": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/nofilter/-/nofilter-3.1.0.tgz", @@ -1406,6 +1605,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "dev": true + }, "node_modules/queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", @@ -1501,6 +1706,26 @@ "queue-microtask": "^1.2.2" } }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/semver": { "version": "7.5.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", @@ -1531,6 +1756,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -1553,16 +1791,10 @@ } }, "node_modules/signal-exit": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", - "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", - "dev": true, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true }, "node_modules/slash": { "version": "4.0.0", @@ -1592,6 +1824,30 @@ "url": "https://github.com/chalk/slice-ansi?sponsor=1" } }, + "node_modules/sodium-native": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/sodium-native/-/sodium-native-4.0.4.tgz", + "integrity": "sha512-faqOKw4WQKK7r/ybn6Lqo1F9+L5T6NlBJJYvpxbZPetpWylUVqz449mvlwIBKBqxEHbWakWuOlUt8J3Qpc4sWw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "dependencies": { + "node-gyp-build": "^4.6.0" + } + }, + "node_modules/soroban-client": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-1.0.0-beta.2.tgz", + "integrity": "sha512-v5h3yvef7HkUD3H26w33NUEgRXcPiOSDWEsVzMloaxsprs3N002tXJHvFF+Uw1eYt50Uk6bvqBgvkLwX10VENw==", + "dev": true, + "dependencies": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "stellar-base": "v10.0.0-beta.1", + "urijs": "^1.19.1" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -1619,6 +1875,23 @@ "node": ">=8" } }, + "node_modules/stellar-base": { + "version": "10.0.0-beta.1", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-beta.1.tgz", + "integrity": "sha512-zXC5AsbUsLi57JruyeIMv23s3iUxq/P2ZFrSJ+FerLIZjSAjY8EDs4zwY4LCuu7swUu46Lm8GK6sqxUZCPekHw==", + "dev": true, + "dependencies": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.2", + "buffer": "^6.0.3", + "js-xdr": "^3.0.0", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.0.1" + } + }, "node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", @@ -1708,6 +1981,12 @@ "node": ">=8.0" } }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", + "dev": true + }, "node_modules/type-fest": { "version": "0.13.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.13.1.tgz", @@ -1721,9 +2000,9 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", @@ -1733,6 +2012,12 @@ "node": ">=14.17" } }, + "node_modules/urijs": { + "version": "1.19.11", + "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.11.tgz", + "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==", + "dev": true + }, "node_modules/well-known-symbols": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/well-known-symbols/-/well-known-symbols-2.0.0.tgz", @@ -1852,6 +2137,18 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/write-file-atomic/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/package.json b/cmd/crates/soroban-spec-typescript/ts-tests/package.json index c840d9335..7ad7212ae 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/package.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/package.json @@ -2,12 +2,21 @@ "private": true, "type": "module", "scripts": { + "postinstall": "npm run deploy && npm run bindings || { echo \"Make sure you're running standalone RPC network on localhost:8000\" && exit 1; }", + "fund": "./soroban config identity fund", + "bindings:custom-types": "./soroban contract bindings typescript --contract-id $(cat contract-id-custom-types.txt) --output-dir ./node_modules/test-custom-types --overwrite", + "bindings:hello-world": "./soroban contract bindings typescript --contract-id $(cat contract-id-hello-world.txt) --output-dir ./node_modules/test-hello-world --overwrite", + "bindings": "npm run bindings:custom-types && npm run bindings:hello-world", + "deploy:custom-types": "(./soroban contract deploy --wasm ../../../../target/wasm32-unknown-unknown/test-wasms/test_custom_types.wasm) > contract-id-custom-types.txt", + "deploy:hello-world": "(./soroban contract deploy --wasm ../../../../target/wasm32-unknown-unknown/test-wasms/test_hello_world.wasm) > contract-id-hello-world.txt", + "deploy": "npm run deploy:custom-types && npm run deploy:hello-world", "test": "ava" }, "devDependencies": { "@ava/typescript": "^4.1.0", "@types/node": "^20.4.9", "ava": "^5.3.1", + "soroban-client": "1.0.0-beta.2", "typescript": "^5.1.6" }, "ava": { @@ -17,5 +26,9 @@ }, "compile": "tsc" } - } + }, + "engines": { + "node": ">=20.0.0", + "npm": ">=9.8.1" + } } diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/soroban b/cmd/crates/soroban-spec-typescript/ts-tests/soroban new file mode 100755 index 000000000..d98f247c9 --- /dev/null +++ b/cmd/crates/soroban-spec-typescript/ts-tests/soroban @@ -0,0 +1,3 @@ +#!/bin/bash + +cargo run --quiet -p soroban-cli -- "$@" diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/src/test.ts b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts similarity index 85% rename from cmd/crates/soroban-spec-typescript/ts-tests/src/test.ts rename to cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts index 589f62b78..1c5d04706 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/src/test.ts +++ b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-custom-types.ts @@ -1,24 +1,8 @@ import test from 'ava' -import { Contract, Ok, Err, networks, Address } from '../../fixtures/test_custom_types/dist/esm/index.js' - -const rpcUrl = 'https://rpc-futurenet.stellar.org' -const publicKey = 'GCBVOLOM32I7OD5TWZQCIXCXML3TK56MDY7ZMTAILIBQHHKPCVU42XYW' -const addr = Address.fromString(publicKey) - -const contract = new Contract({ - ...networks.futurenet, - rpcUrl, - wallet: { - isConnected: () => Promise.resolve(true), - isAllowed: () => Promise.resolve(true), - getUserInfo: () => Promise.resolve({ publicKey }), - signTransaction: async (tx: string, opts?: { - network?: string, - networkPassphrase?: string, - accountToSign?: string, - }) => tx, - }, -}) +import { publicKey, rpcUrl, wallet } from './util.js' +import { Contract, Ok, Err, networks, Address } from 'test-custom-types' + +const contract = new Contract({ ...networks.standalone, rpcUrl, wallet}); test('hello', async t => { t.is(await contract.hello({ hello: 'tests' }), 'tests') @@ -89,8 +73,8 @@ test('complex with enum', async t => { }) test('complex with asset', async t => { - const arg = { tag: 'Asset', values: [addr, 1n] } as const - const ret = { tag: 'Asset', values: [addr, 1n] } + const arg = { tag: 'Asset', values: [publicKey, 1n] } as const + const ret = { tag: 'Asset', values: [new Address(publicKey), 1n] } t.deepEqual(await contract.complex({ complex: arg }), ret) }) @@ -100,7 +84,7 @@ test('complex with void', async t => { }) test('addresse', async t => { - t.deepEqual(await contract.addresse({ addresse: addr }), addr) + t.deepEqual(await contract.addresse({ addresse: publicKey }), Address.fromString(publicKey)) }) test('bytes', async t => { @@ -186,4 +170,4 @@ test('tuple_strukt', async t => { const arg = [{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }] as const const res = [{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }] t.deepEqual(await contract.tupleStrukt({ tuple_strukt: arg }), res) -}) \ No newline at end of file +}) diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/src/test-hello-world.ts b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-hello-world.ts new file mode 100644 index 000000000..dc8367931 --- /dev/null +++ b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-hello-world.ts @@ -0,0 +1,20 @@ +import test from "ava"; +import { wallet, publicKey, rpcUrl } from "./util.js"; +import { Address, Contract, networks } from "test-hello-world"; + +const contract = new Contract({...networks.standalone, rpcUrl, wallet}); + +test("hello", async (t) => { + t.deepEqual(await contract.hello({ world: "tests" }), ["Hello", "tests"]); +}); + +// Currently must run tests in serial because nonce logic not smart enough to handle concurrent calls. +test.serial.failing("auth", async (t) => { + t.deepEqual(await contract.auth({ addr: publicKey, world: 'lol' }), Address.fromString(publicKey)) +}); + +test.serial.failing("inc", async (t) => { + t.is(await contract.getCount(), 0); + t.is(await contract.inc(), 1) + t.is(await contract.getCount(), 1); +}); diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/src/test-methods-as-args.ts b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-methods-as-args.ts new file mode 100644 index 000000000..dfa7c4724 --- /dev/null +++ b/cmd/crates/soroban-spec-typescript/ts-tests/src/test-methods-as-args.ts @@ -0,0 +1,12 @@ +import test from "ava"; +import { wallet, rpcUrl } from "./util.js"; +import { Contract, networks } from "test-hello-world"; + +const contract = new Contract({...networks.standalone, rpcUrl, wallet}); + +// this test checks that apps can pass methods as arguments to other methods and have them still work +const hello = contract.hello + +test("hello", async (t) => { + t.deepEqual(await hello({ world: "tests" }), ["Hello", "tests"]); +}); diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/src/util.ts b/cmd/crates/soroban-spec-typescript/ts-tests/src/util.ts new file mode 100644 index 000000000..81517944f --- /dev/null +++ b/cmd/crates/soroban-spec-typescript/ts-tests/src/util.ts @@ -0,0 +1,27 @@ +import { Keypair, TransactionBuilder } from "soroban-client"; + +export const rpcUrl = process.env.SOROBAN_RPC_URL ?? "http://localhost:8000/"; +export const secretKey = + "SC36BWNUOCZAO7DMEJNNKFV6BOTPJP7IG5PSHLUOLT6DZFRU3D3XGIXW"; + +const keypair = Keypair.fromSecret(secretKey); +export const publicKey = keypair.publicKey(); +const networkPassphrase = "Standalone Network ; February 2017"; + +export const wallet = { + isConnected: () => Promise.resolve(true), + isAllowed: () => Promise.resolve(true), + getUserInfo: () => Promise.resolve({ publicKey }), + signTransaction: async ( + tx: string, + _opts?: { + network?: string; + networkPassphrase?: string; + accountToSign?: string; + } + ) => { + const t = TransactionBuilder.fromXDR(tx, networkPassphrase); + t.sign(keypair); + return t.toXDR(); + }, +}; diff --git a/cmd/crates/soroban-spec-typescript/ts-tests/tsconfig.json b/cmd/crates/soroban-spec-typescript/ts-tests/tsconfig.json index 36823a0e2..b90870f4e 100644 --- a/cmd/crates/soroban-spec-typescript/ts-tests/tsconfig.json +++ b/cmd/crates/soroban-spec-typescript/ts-tests/tsconfig.json @@ -22,9 +22,9 @@ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ /* Modules */ - "module": "ESNext", /* Specify what module code is generated. */ + "module": "NodeNext", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ - "moduleResolution": "nodenext", /* Specify how TypeScript looks up a file from a given module specifier. */ + "moduleResolution": "NodeNext", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ @@ -98,4 +98,4 @@ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ } -} \ No newline at end of file +} diff --git a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/src/lib.rs b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/src/lib.rs index 7dc1e7087..03077ad57 100644 --- a/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/src/lib.rs +++ b/cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world/src/lib.rs @@ -30,6 +30,12 @@ impl Contract { addr } + // get current count + pub fn get_count(env: Env) -> u32 { + env.storage().persistent().get(&COUNTER).unwrap_or(0) + } + + // increment count and return new one pub fn inc(env: Env) -> u32 { let mut count: u32 = env.storage().persistent().get(&COUNTER).unwrap_or(0); // Panic if the value of COUNTER is not u32. log!(&env, "count: {}", count); From 91c21c5348c61b590384929992abf93c6cdb59d7 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:23:44 -0400 Subject: [PATCH 2/3] build: bump delta for flaky test --- cmd/soroban-rpc/internal/test/simulate_transaction_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index e1c02b8e4..f4f6c9956 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -244,7 +244,7 @@ func TestSimulateTransactionSucceeds(t *testing.T) { err := xdr.SafeUnmarshalBase64(result.TransactionData, &transactionData) assert.NoError(t, err) assert.Equal(t, expectedTransactionData.Resources.Footprint, transactionData.Resources.Footprint) - assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 100000) + assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 200000) assert.InDelta(t, uint32(expectedTransactionData.Resources.ReadBytes), uint32(transactionData.Resources.ReadBytes), 10) assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 100) assert.InDelta(t, int64(expectedTransactionData.RefundableFee), int64(transactionData.RefundableFee), 1000) From de7aaf50eda466303636e55f05be74f364ee52f5 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:03:56 -0400 Subject: [PATCH 3/3] build: increase deltas in cli simulation test --- cmd/soroban-rpc/internal/test/simulate_transaction_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go index f4f6c9956..13eb9b894 100644 --- a/cmd/soroban-rpc/internal/test/simulate_transaction_test.go +++ b/cmd/soroban-rpc/internal/test/simulate_transaction_test.go @@ -246,8 +246,8 @@ func TestSimulateTransactionSucceeds(t *testing.T) { assert.Equal(t, expectedTransactionData.Resources.Footprint, transactionData.Resources.Footprint) assert.InDelta(t, uint32(expectedTransactionData.Resources.Instructions), uint32(transactionData.Resources.Instructions), 200000) assert.InDelta(t, uint32(expectedTransactionData.Resources.ReadBytes), uint32(transactionData.Resources.ReadBytes), 10) - assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 100) - assert.InDelta(t, int64(expectedTransactionData.RefundableFee), int64(transactionData.RefundableFee), 1000) + assert.InDelta(t, uint32(expectedTransactionData.Resources.WriteBytes), uint32(transactionData.Resources.WriteBytes), 500) + assert.InDelta(t, int64(expectedTransactionData.RefundableFee), int64(transactionData.RefundableFee), 2000) // Then decode and check the result xdr, separately so we get a decent diff if it fails. assert.Len(t, result.Results, 1)