@kynesyslabs/demosdk 4.0.12 → 4.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/abstraction/Identities.d.ts +65 -21
- package/build/abstraction/Identities.js +51 -50
- package/build/abstraction/Identities.js.map +1 -1
- package/build/bridge/nativeBridge.d.ts +3 -1
- package/build/bridge/nativeBridge.js +4 -3
- package/build/bridge/nativeBridge.js.map +1 -1
- package/build/contracts/ContractDeployer.js +5 -2
- package/build/contracts/ContractDeployer.js.map +1 -1
- package/build/contracts/ContractInteractor.js +4 -1
- package/build/contracts/ContractInteractor.js.map +1 -1
- package/build/d402/client/D402Client.d.ts +3 -1
- package/build/d402/client/D402Client.js +4 -3
- package/build/d402/client/D402Client.js.map +1 -1
- package/build/escrow/EscrowTransaction.d.ts +7 -2
- package/build/escrow/EscrowTransaction.js +9 -8
- package/build/escrow/EscrowTransaction.js.map +1 -1
- package/build/l2ps/anchor/anchor.d.ts +1 -0
- package/build/l2ps/anchor/anchor.js +4 -3
- package/build/l2ps/anchor/anchor.js.map +1 -1
- package/build/l2ps/binding/binding.d.ts +3 -1
- package/build/l2ps/binding/binding.js +3 -2
- package/build/l2ps/binding/binding.js.map +1 -1
- package/build/tlsnotary/TLSNotaryService.d.ts +2 -0
- package/build/tlsnotary/TLSNotaryService.js +11 -10
- package/build/tlsnotary/TLSNotaryService.js.map +1 -1
- package/build/types/blockchain/GCREdit.d.ts +0 -30
- package/build/types/blockchain/Transaction.d.ts +7 -0
- package/build/types/blockchain/Transaction.js.map +1 -1
- package/build/types/blockchain/rawTransaction.d.ts +2 -7
- package/build/types/web2/index.d.ts +1 -0
- package/build/utils/index.d.ts +2 -0
- package/build/utils/index.js +12 -0
- package/build/utils/index.js.map +1 -1
- package/build/websdk/DemosTokens.d.ts +42 -14
- package/build/websdk/DemosTokens.js +35 -30
- package/build/websdk/DemosTokens.js.map +1 -1
- package/build/websdk/DemosTransactions.d.ts +29 -11
- package/build/websdk/DemosTransactions.js +30 -29
- package/build/websdk/DemosTransactions.js.map +1 -1
- package/build/websdk/Web2Calls.js +3 -2
- package/build/websdk/Web2Calls.js.map +1 -1
- package/build/websdk/demosclass.d.ts +177 -33
- package/build/websdk/demosclass.js +102 -13
- package/build/websdk/demosclass.js.map +1 -1
- package/build/websdk/index.d.ts +1 -0
- package/build/websdk/index.js +3 -0
- package/build/websdk/index.js.map +1 -1
- package/build/websdk/programmatic/ProgrammaticTx.d.ts +118 -0
- package/build/websdk/programmatic/ProgrammaticTx.js +56 -0
- package/build/websdk/programmatic/ProgrammaticTx.js.map +1 -0
- package/build/websdk/programmatic/attest.d.ts +396 -0
- package/build/websdk/programmatic/attest.js +418 -0
- package/build/websdk/programmatic/attest.js.map +1 -0
- package/build/websdk/programmatic/bridge.d.ts +36 -0
- package/build/websdk/programmatic/bridge.js +37 -0
- package/build/websdk/programmatic/bridge.js.map +1 -0
- package/build/websdk/programmatic/context.d.ts +26 -0
- package/build/websdk/programmatic/context.js +9 -0
- package/build/websdk/programmatic/context.js.map +1 -0
- package/build/websdk/programmatic/contracts.d.ts +79 -0
- package/build/websdk/programmatic/contracts.js +81 -0
- package/build/websdk/programmatic/contracts.js.map +1 -0
- package/build/websdk/programmatic/d402.d.ts +33 -0
- package/build/websdk/programmatic/d402.js +35 -0
- package/build/websdk/programmatic/d402.js.map +1 -0
- package/build/websdk/programmatic/demoswork.d.ts +37 -0
- package/build/websdk/programmatic/demoswork.js +38 -0
- package/build/websdk/programmatic/demoswork.js.map +1 -0
- package/build/websdk/programmatic/errors.d.ts +20 -0
- package/build/websdk/programmatic/errors.js +24 -0
- package/build/websdk/programmatic/errors.js.map +1 -0
- package/build/websdk/programmatic/escrow.d.ts +75 -0
- package/build/websdk/programmatic/escrow.js +74 -0
- package/build/websdk/programmatic/escrow.js.map +1 -0
- package/build/websdk/programmatic/governance.d.ts +59 -0
- package/build/websdk/programmatic/governance.js +48 -0
- package/build/websdk/programmatic/governance.js.map +1 -0
- package/build/websdk/programmatic/index.d.ts +30 -0
- package/build/websdk/programmatic/index.js +31 -0
- package/build/websdk/programmatic/index.js.map +1 -0
- package/build/websdk/programmatic/ipfs.d.ts +74 -0
- package/build/websdk/programmatic/ipfs.js +106 -0
- package/build/websdk/programmatic/ipfs.js.map +1 -0
- package/build/websdk/programmatic/pay.d.ts +36 -0
- package/build/websdk/programmatic/pay.js +37 -0
- package/build/websdk/programmatic/pay.js.map +1 -0
- package/build/websdk/programmatic/runner.d.ts +30 -0
- package/build/websdk/programmatic/runner.js +188 -0
- package/build/websdk/programmatic/runner.js.map +1 -0
- package/build/websdk/programmatic/storage.d.ts +49 -0
- package/build/websdk/programmatic/storage.js +51 -0
- package/build/websdk/programmatic/storage.js.map +1 -0
- package/build/websdk/programmatic/tokens.d.ts +155 -0
- package/build/websdk/programmatic/tokens.js +171 -0
- package/build/websdk/programmatic/tokens.js.map +1 -0
- package/build/websdk/programmatic/types.d.ts +96 -0
- package/build/websdk/programmatic/types.js +8 -0
- package/build/websdk/programmatic/types.js.map +1 -0
- package/build/websdk/programmatic/validator.d.ts +63 -0
- package/build/websdk/programmatic/validator.js +68 -0
- package/build/websdk/programmatic/validator.js.map +1 -0
- package/build/websdk/programmatic/xm.d.ts +36 -0
- package/build/websdk/programmatic/xm.js +37 -0
- package/build/websdk/programmatic/xm.js.map +1 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { EnumWeb2Actions } from "../types/index.js";
|
|
|
2
2
|
import { web2_request } from "./utils/skeletons.js";
|
|
3
3
|
import { DemosTransactions } from "./DemosTransactions.js";
|
|
4
4
|
import { canonicalJSONStringify, validatePureJson, looksLikeJsonString, } from "./utils/canonicalJson.js";
|
|
5
|
+
import { resolveNonce } from "../utils/index.js";
|
|
5
6
|
class Web2InvalidUrlError extends Error {
|
|
6
7
|
constructor(message, code) {
|
|
7
8
|
super(message);
|
|
@@ -134,8 +135,8 @@ export class Web2Proxy {
|
|
|
134
135
|
web2Tx.content.type = "web2Request";
|
|
135
136
|
web2Tx.content.data = ["web2Request", web2Payload];
|
|
136
137
|
web2Tx.content.timestamp = Date.now();
|
|
137
|
-
const nonce = await this._demos.getAddressNonce(await this._demos.getEd25519Address());
|
|
138
|
-
web2Tx.content.nonce = nonce
|
|
138
|
+
const nonce = await resolveNonce(options?.nonce, async () => this._demos.getAddressNonce(await this._demos.getEd25519Address()));
|
|
139
|
+
web2Tx.content.nonce = nonce;
|
|
139
140
|
const signedWeb2Tx = await this._demos.sign(web2Tx);
|
|
140
141
|
const validityData = await this._demos.confirm(signedWeb2Tx);
|
|
141
142
|
const txHash = validityData.response.data.transaction.hash;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Web2Calls.js","sourceRoot":"","sources":["../../../src/websdk/Web2Calls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,GACtB,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"Web2Calls.js","sourceRoot":"","sources":["../../../src/websdk/Web2Calls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAEvD,OAAO,EACH,sBAAsB,EACtB,gBAAgB,EAChB,mBAAmB,GACtB,MAAM,uBAAuB,CAAA;AAO9B,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,MAAM,mBAAoB,SAAQ,KAAK;IAEnC,YAAY,OAAe,EAAE,IAAY;QACrC,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,I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AC,CAAA;IAC1C,CAAC;CACJ,CAAA"}
|
|
@@ -7,6 +7,7 @@ import type { ValidatorInfo } from "../types/validator/ValidatorTypes";
|
|
|
7
7
|
import type { NetworkParameters, NetworkUpgradeProposal, ProposalVoteInfo } from "../types/blockchain/NetworkParameters";
|
|
8
8
|
import { RPCRequest, RPCResponse, RPCResponseWithValidityData } from "../types/communication/rpc";
|
|
9
9
|
import { IKeyPair } from "./types/KeyPair";
|
|
10
|
+
import { type ProgrammaticTx } from "./programmatic";
|
|
10
11
|
import { UnifiedCrypto } from "../encryption/unifiedCrypto";
|
|
11
12
|
import { type NetworkInfo } from "../denomination/networkInfo";
|
|
12
13
|
import { TweetSimplified } from "../types";
|
|
@@ -67,6 +68,50 @@ export declare class Demos {
|
|
|
67
68
|
* @returns Whether the connection was successful
|
|
68
69
|
*/
|
|
69
70
|
connect(rpc_url: string): Promise<boolean>;
|
|
71
|
+
/**
|
|
72
|
+
* One-call bootstrap: connect to a node and (optionally) a wallet, then
|
|
73
|
+
* return the ready instance for immediate use with `demos.run.*`.
|
|
74
|
+
*
|
|
75
|
+
* Convenience wrapper over {@link connect} + {@link connectWallet} — no
|
|
76
|
+
* new behaviour, just the two-step setup collapsed into one. Omit
|
|
77
|
+
* `wallet` to connect read-only.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { Demos } from "@kynesyslabs/demosdk/websdk"
|
|
82
|
+
* const demos = await Demos.start("https://node2.demos.sh", mnemonic)
|
|
83
|
+
* await demos.run.pay("0x...", 100n)
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @param rpc_url - The URL of the demos node.
|
|
87
|
+
* @param wallet - Master seed / mnemonic (string) or raw seed bytes.
|
|
88
|
+
* Omit to connect without a wallet.
|
|
89
|
+
* @param walletOptions - Forwarded to {@link connectWallet}.
|
|
90
|
+
* @returns This connected Demos instance.
|
|
91
|
+
*/
|
|
92
|
+
start(rpc_url: string, wallet?: string | Uint8Array, walletOptions?: {
|
|
93
|
+
algorithm?: SigningAlgorithm;
|
|
94
|
+
dual_sign?: boolean;
|
|
95
|
+
}): Promise<this>;
|
|
96
|
+
/**
|
|
97
|
+
* Static one-call bootstrap over the shared singleton — starts
|
|
98
|
+
* {@link Demos.instance} and returns it ready for `demos.run.*`.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* const demos = await Demos.start("https://node2.demos.sh", mnemonic)
|
|
103
|
+
* await demos.run.pay("0x...", 100n)
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @param rpc_url - The URL of the demos node.
|
|
107
|
+
* @param wallet - Master seed / mnemonic (string) or raw seed bytes.
|
|
108
|
+
* @param walletOptions - Forwarded to {@link connectWallet}.
|
|
109
|
+
* @returns The started shared Demos instance.
|
|
110
|
+
*/
|
|
111
|
+
static start(rpc_url: string, wallet?: string | Uint8Array, walletOptions?: {
|
|
112
|
+
algorithm?: SigningAlgorithm;
|
|
113
|
+
dual_sign?: boolean;
|
|
114
|
+
}): Promise<Demos>;
|
|
70
115
|
/**
|
|
71
116
|
* Connects to a Demos wallet using the provided master seed.
|
|
72
117
|
*
|
|
@@ -133,7 +178,9 @@ export declare class Demos {
|
|
|
133
178
|
* @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
|
|
134
179
|
* @returns The signed transaction.
|
|
135
180
|
*/
|
|
136
|
-
pay(to: string, amount: number | bigint
|
|
181
|
+
pay(to: string, amount: number | bigint, options?: {
|
|
182
|
+
nonce?: number;
|
|
183
|
+
}): Promise<Transaction>;
|
|
137
184
|
/**
|
|
138
185
|
* Create a signed DEMOS transaction to send native tokens to a given address.
|
|
139
186
|
*
|
|
@@ -151,7 +198,9 @@ export declare class Demos {
|
|
|
151
198
|
* @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
|
|
152
199
|
* @returns The signed transaction.
|
|
153
200
|
*/
|
|
154
|
-
transfer(to: string, amount: number | bigint
|
|
201
|
+
transfer(to: string, amount: number | bigint, options?: {
|
|
202
|
+
nonce?: number;
|
|
203
|
+
}): Promise<Transaction>;
|
|
155
204
|
/**
|
|
156
205
|
* Create a signed DEMOS transaction to store binary data on the blockchain.
|
|
157
206
|
* Data is stored in the sender's account.
|
|
@@ -160,7 +209,9 @@ export declare class Demos {
|
|
|
160
209
|
*
|
|
161
210
|
* @returns The signed storage transaction.
|
|
162
211
|
*/
|
|
163
|
-
store(bytes: Uint8Array
|
|
212
|
+
store(bytes: Uint8Array, options?: {
|
|
213
|
+
nonce?: number;
|
|
214
|
+
}): Promise<Transaction>;
|
|
164
215
|
storagePrograms: {
|
|
165
216
|
/**
|
|
166
217
|
* Creates and signs a storage program transaction given a payload.
|
|
@@ -169,7 +220,9 @@ export declare class Demos {
|
|
|
169
220
|
* @returns The signed transaction
|
|
170
221
|
*
|
|
171
222
|
*/
|
|
172
|
-
sign: (payload: StorageProgramPayload
|
|
223
|
+
sign: (payload: StorageProgramPayload, options?: {
|
|
224
|
+
nonce?: number;
|
|
225
|
+
}) => Promise<Transaction>;
|
|
173
226
|
/**
|
|
174
227
|
* Reads a storage program by address.
|
|
175
228
|
*
|
|
@@ -202,7 +255,7 @@ export declare class Demos {
|
|
|
202
255
|
* handle async confirmation yourself.
|
|
203
256
|
*
|
|
204
257
|
* @param validationData - The validity data of the transaction
|
|
205
|
-
* @param opts.timeoutMs - Total time to wait. Defaults to
|
|
258
|
+
* @param opts.timeoutMs - Total time to wait. Defaults to 60_000.
|
|
206
259
|
* @param opts.pollIntervalMs - Delay between polls. Defaults to 500.
|
|
207
260
|
*/
|
|
208
261
|
broadcastAndWait(validationData: RPCResponseWithValidityData, opts?: {
|
|
@@ -222,7 +275,9 @@ export declare class Demos {
|
|
|
222
275
|
* @param options - The dual-signing options
|
|
223
276
|
* @returns The signed transaction
|
|
224
277
|
*/
|
|
225
|
-
sign(raw_tx: Transaction
|
|
278
|
+
sign(raw_tx: Transaction, options?: {
|
|
279
|
+
nonce?: number;
|
|
280
|
+
}): Promise<Transaction>;
|
|
226
281
|
/**
|
|
227
282
|
* Signs a message.
|
|
228
283
|
*
|
|
@@ -619,9 +674,13 @@ export declare class Demos {
|
|
|
619
674
|
sign: (raw_tx: Transaction) => Promise<Transaction>;
|
|
620
675
|
empty: () => Transaction;
|
|
621
676
|
prepare: (data?: any) => Promise<Transaction>;
|
|
622
|
-
pay(to: string, amount: number | bigint, demos: Demos
|
|
677
|
+
pay(to: string, amount: number | bigint, demos: Demos, options?: {
|
|
678
|
+
nonce?: number;
|
|
679
|
+
}): Promise<Transaction>;
|
|
623
680
|
_demNumberToOsBigint(amountDem: number): bigint;
|
|
624
|
-
transfer(to: string, amount: number | bigint, demos: Demos
|
|
681
|
+
transfer(to: string, amount: number | bigint, demos: Demos, options?: {
|
|
682
|
+
nonce?: number;
|
|
683
|
+
}): Promise<Transaction>;
|
|
625
684
|
signWithAlgorithm: (data: string, keypair: IKeyPair, options: {
|
|
626
685
|
algorithm: SigningAlgorithm;
|
|
627
686
|
}) => Promise<{
|
|
@@ -641,25 +700,78 @@ export declare class Demos {
|
|
|
641
700
|
blockNumber?: number;
|
|
642
701
|
};
|
|
643
702
|
}>;
|
|
644
|
-
store(bytes: Uint8Array, demos: Demos
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
703
|
+
store(bytes: Uint8Array, demos: Demos, options?: {
|
|
704
|
+
nonce?: number;
|
|
705
|
+
}): Promise<Transaction>;
|
|
706
|
+
createL2PSHashUpdate(l2psUid: string, consolidatedHash: string, transactionCount: number, demos: Demos, options?: {
|
|
707
|
+
nonce?: number;
|
|
708
|
+
}): Promise<Transaction>;
|
|
709
|
+
stake(amount: string, connectionUrl: string, demos: Demos, options?: {
|
|
710
|
+
nonce?: number;
|
|
711
|
+
}): Promise<Transaction>;
|
|
712
|
+
unstake(demos: Demos, options?: {
|
|
713
|
+
nonce?: number;
|
|
714
|
+
}): Promise<Transaction>;
|
|
715
|
+
validatorExit(demos: Demos, options?: {
|
|
716
|
+
nonce?: number;
|
|
717
|
+
}): Promise<Transaction>;
|
|
649
718
|
proposeNetworkUpgrade(params: {
|
|
650
719
|
proposalId: string;
|
|
651
720
|
proposedParameters: Partial<NetworkParameters>;
|
|
652
721
|
rationale: string;
|
|
653
722
|
effectiveAtBlock: number;
|
|
654
|
-
}, demos: Demos
|
|
655
|
-
|
|
723
|
+
}, demos: Demos, options?: {
|
|
724
|
+
nonce?: number;
|
|
725
|
+
}): Promise<Transaction>;
|
|
726
|
+
voteOnUpgrade(proposalId: string, approve: boolean, demos: Demos, options?: {
|
|
727
|
+
nonce?: number;
|
|
728
|
+
}): Promise<Transaction>;
|
|
656
729
|
};
|
|
730
|
+
private _run?;
|
|
731
|
+
/**
|
|
732
|
+
* Programmatic transaction facade — one call per transaction type.
|
|
733
|
+
*
|
|
734
|
+
* Collapses the classic `build → sign → confirm → broadcast` flow into a
|
|
735
|
+
* single method per operation (`run.pay`, `run.attest.*`, `run.tokens.*`,
|
|
736
|
+
* …) that auto-broadcasts within a configurable fee ceiling (default
|
|
737
|
+
* 5 DEM). Additive: the classic `pay`/`confirm`/`broadcast` methods are
|
|
738
|
+
* unchanged.
|
|
739
|
+
*
|
|
740
|
+
* Built lazily on first access (and memoised) rather than in the
|
|
741
|
+
* constructor. Two reasons: (1) the singleton `demos = Demos.instance` is
|
|
742
|
+
* created at import time, so eagerly *constructing* the namespaces during
|
|
743
|
+
* `new Demos()` — which reach into `@/abstraction`, tokens, contracts — is
|
|
744
|
+
* the part that risked tripping the websdk↔abstraction import cycle;
|
|
745
|
+
* deferring construction removes that crash vector. (2) it avoids building
|
|
746
|
+
* ~6 objects on every `new Demos()` that many callers never touch.
|
|
747
|
+
*
|
|
748
|
+
* Note: the programmatic module graph is still *loaded* when this file is
|
|
749
|
+
* imported (a static `import` cannot be deferred in ESM). That residual
|
|
750
|
+
* cycle is benign — no module reads a cross-cycle binding at evaluation
|
|
751
|
+
* time, only inside functions — and has been narrowed by importing
|
|
752
|
+
* `Identities` directly from `@/abstraction/Identities` rather than via the
|
|
753
|
+
* `@/abstraction` barrel.
|
|
754
|
+
*
|
|
755
|
+
* @example
|
|
756
|
+
* ```ts
|
|
757
|
+
* // one-call payment, auto-broadcast within the 5 DEM fee cap
|
|
758
|
+
* await demos.run.pay("0x...", 100n)
|
|
759
|
+
* // build + confirm only, broadcast yourself later
|
|
760
|
+
* const r = await demos.run.pay("0x...", 100n, { confirm: "manual" })
|
|
761
|
+
* await demos.broadcast(r.validityData)
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
get run(): ProgrammaticTx;
|
|
657
765
|
DemosTransactions: {
|
|
658
766
|
empty: () => Transaction;
|
|
659
767
|
prepare: (data?: any) => Promise<Transaction>;
|
|
660
|
-
pay(to: string, amount: number | bigint, demos: Demos
|
|
768
|
+
pay(to: string, amount: number | bigint, demos: Demos, options?: {
|
|
769
|
+
nonce?: number;
|
|
770
|
+
}): Promise<Transaction>;
|
|
661
771
|
_demNumberToOsBigint(amountDem: number): bigint;
|
|
662
|
-
transfer(to: string, amount: number | bigint, demos: Demos
|
|
772
|
+
transfer(to: string, amount: number | bigint, demos: Demos, options?: {
|
|
773
|
+
nonce?: number;
|
|
774
|
+
}): Promise<Transaction>;
|
|
663
775
|
sign: (raw_tx: Transaction, keypair: IKeyPair, options: {
|
|
664
776
|
algorithm: SigningAlgorithm;
|
|
665
777
|
}) => Promise<Transaction>;
|
|
@@ -682,25 +794,43 @@ export declare class Demos {
|
|
|
682
794
|
blockNumber?: number;
|
|
683
795
|
};
|
|
684
796
|
}>;
|
|
685
|
-
store(bytes: Uint8Array, demos: Demos
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
797
|
+
store(bytes: Uint8Array, demos: Demos, options?: {
|
|
798
|
+
nonce?: number;
|
|
799
|
+
}): Promise<Transaction>;
|
|
800
|
+
createL2PSHashUpdate(l2psUid: string, consolidatedHash: string, transactionCount: number, demos: Demos, options?: {
|
|
801
|
+
nonce?: number;
|
|
802
|
+
}): Promise<Transaction>;
|
|
803
|
+
stake(amount: string, connectionUrl: string, demos: Demos, options?: {
|
|
804
|
+
nonce?: number;
|
|
805
|
+
}): Promise<Transaction>;
|
|
806
|
+
unstake(demos: Demos, options?: {
|
|
807
|
+
nonce?: number;
|
|
808
|
+
}): Promise<Transaction>;
|
|
809
|
+
validatorExit(demos: Demos, options?: {
|
|
810
|
+
nonce?: number;
|
|
811
|
+
}): Promise<Transaction>;
|
|
690
812
|
proposeNetworkUpgrade(params: {
|
|
691
813
|
proposalId: string;
|
|
692
814
|
proposedParameters: Partial<NetworkParameters>;
|
|
693
815
|
rationale: string;
|
|
694
816
|
effectiveAtBlock: number;
|
|
695
|
-
}, demos: Demos
|
|
696
|
-
|
|
817
|
+
}, demos: Demos, options?: {
|
|
818
|
+
nonce?: number;
|
|
819
|
+
}): Promise<Transaction>;
|
|
820
|
+
voteOnUpgrade(proposalId: string, approve: boolean, demos: Demos, options?: {
|
|
821
|
+
nonce?: number;
|
|
822
|
+
}): Promise<Transaction>;
|
|
697
823
|
};
|
|
698
824
|
transactions: {
|
|
699
825
|
empty: () => Transaction;
|
|
700
826
|
prepare: (data?: any) => Promise<Transaction>;
|
|
701
|
-
pay(to: string, amount: number | bigint, demos: Demos
|
|
827
|
+
pay(to: string, amount: number | bigint, demos: Demos, options?: {
|
|
828
|
+
nonce?: number;
|
|
829
|
+
}): Promise<Transaction>;
|
|
702
830
|
_demNumberToOsBigint(amountDem: number): bigint;
|
|
703
|
-
transfer(to: string, amount: number | bigint, demos: Demos
|
|
831
|
+
transfer(to: string, amount: number | bigint, demos: Demos, options?: {
|
|
832
|
+
nonce?: number;
|
|
833
|
+
}): Promise<Transaction>;
|
|
704
834
|
sign: (raw_tx: Transaction, keypair: IKeyPair, options: {
|
|
705
835
|
algorithm: SigningAlgorithm;
|
|
706
836
|
}) => Promise<Transaction>;
|
|
@@ -723,18 +853,32 @@ export declare class Demos {
|
|
|
723
853
|
blockNumber?: number;
|
|
724
854
|
};
|
|
725
855
|
}>;
|
|
726
|
-
store(bytes: Uint8Array, demos: Demos
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
856
|
+
store(bytes: Uint8Array, demos: Demos, options?: {
|
|
857
|
+
nonce?: number;
|
|
858
|
+
}): Promise<Transaction>;
|
|
859
|
+
createL2PSHashUpdate(l2psUid: string, consolidatedHash: string, transactionCount: number, demos: Demos, options?: {
|
|
860
|
+
nonce?: number;
|
|
861
|
+
}): Promise<Transaction>;
|
|
862
|
+
stake(amount: string, connectionUrl: string, demos: Demos, options?: {
|
|
863
|
+
nonce?: number;
|
|
864
|
+
}): Promise<Transaction>;
|
|
865
|
+
unstake(demos: Demos, options?: {
|
|
866
|
+
nonce?: number;
|
|
867
|
+
}): Promise<Transaction>;
|
|
868
|
+
validatorExit(demos: Demos, options?: {
|
|
869
|
+
nonce?: number;
|
|
870
|
+
}): Promise<Transaction>;
|
|
731
871
|
proposeNetworkUpgrade(params: {
|
|
732
872
|
proposalId: string;
|
|
733
873
|
proposedParameters: Partial<NetworkParameters>;
|
|
734
874
|
rationale: string;
|
|
735
875
|
effectiveAtBlock: number;
|
|
736
|
-
}, demos: Demos
|
|
737
|
-
|
|
876
|
+
}, demos: Demos, options?: {
|
|
877
|
+
nonce?: number;
|
|
878
|
+
}): Promise<Transaction>;
|
|
879
|
+
voteOnUpgrade(proposalId: string, approve: boolean, demos: Demos, options?: {
|
|
880
|
+
nonce?: number;
|
|
881
|
+
}): Promise<Transaction>;
|
|
738
882
|
};
|
|
739
883
|
DemosWebAuth: typeof DemosWebAuth;
|
|
740
884
|
skeletons: typeof skeletons;
|
|
@@ -12,10 +12,12 @@ import { DemosWebAuth } from "./DemosWebAuth.js";
|
|
|
12
12
|
import { prepareXMPayload } from "./XMTransactions.js";
|
|
13
13
|
import { _required as required } from "./utils/required.js";
|
|
14
14
|
import { web2Calls } from "./Web2Calls.js";
|
|
15
|
+
import { createProgrammaticTx, } from "./programmatic/index.js";
|
|
15
16
|
import { hexToUint8Array, uint8ArrayToHex, UnifiedCrypto, } from "../encryption/unifiedCrypto.js";
|
|
16
17
|
import { GCRGeneration } from "./GCRGeneration.js";
|
|
17
18
|
import { Hashing } from "../encryption/Hashing.js";
|
|
18
19
|
import { OS_PER_DEM, demToOs, parseOsString } from "../denomination/index.js";
|
|
20
|
+
import { assertValidNonce, resolveNonce } from "../utils/index.js";
|
|
19
21
|
import { serializeTransactionContent } from "../denomination/serializerGate.js";
|
|
20
22
|
import { SubDemPrecisionError, } from "../denomination/networkInfo.js";
|
|
21
23
|
import * as bip39 from "@scure/bip39";
|
|
@@ -87,7 +89,7 @@ export class Demos {
|
|
|
87
89
|
* @returns The signed transaction
|
|
88
90
|
*
|
|
89
91
|
*/
|
|
90
|
-
sign: async (payload) => {
|
|
92
|
+
sign: async (payload, options) => {
|
|
91
93
|
required(this.keypair, "Wallet not connected");
|
|
92
94
|
required(payload.storageAddress, "Storage address Not found in payload");
|
|
93
95
|
// Sender's nonce must be set on the tx like every other
|
|
@@ -97,13 +99,15 @@ export class Demos {
|
|
|
97
99
|
// txs ship with the skeleton default nonce 0 and get rejected
|
|
98
100
|
// by the node's sequential-nonce / expectedPrior enforcement
|
|
99
101
|
// after the first one.
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
const nonce = await resolveNonce(options?.nonce, async () => {
|
|
103
|
+
const { publicKey } = await this.crypto.getIdentity("ed25519");
|
|
104
|
+
const publicKeyHex = uint8ArrayToHex(publicKey);
|
|
105
|
+
return this.getAddressNonce(publicKeyHex);
|
|
106
|
+
});
|
|
103
107
|
const tx = DemosTransactions.empty();
|
|
104
108
|
tx.content.to = payload.storageAddress;
|
|
105
109
|
tx.content.type = "storageProgram";
|
|
106
|
-
tx.content.nonce = nonce
|
|
110
|
+
tx.content.nonce = nonce;
|
|
107
111
|
tx.content.data = ["storageProgram", payload];
|
|
108
112
|
return await this.sign(tx);
|
|
109
113
|
},
|
|
@@ -276,6 +280,52 @@ export class Demos {
|
|
|
276
280
|
this.connected = true;
|
|
277
281
|
return this.connected;
|
|
278
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* One-call bootstrap: connect to a node and (optionally) a wallet, then
|
|
285
|
+
* return the ready instance for immediate use with `demos.run.*`.
|
|
286
|
+
*
|
|
287
|
+
* Convenience wrapper over {@link connect} + {@link connectWallet} — no
|
|
288
|
+
* new behaviour, just the two-step setup collapsed into one. Omit
|
|
289
|
+
* `wallet` to connect read-only.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { Demos } from "@kynesyslabs/demosdk/websdk"
|
|
294
|
+
* const demos = await Demos.start("https://node2.demos.sh", mnemonic)
|
|
295
|
+
* await demos.run.pay("0x...", 100n)
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @param rpc_url - The URL of the demos node.
|
|
299
|
+
* @param wallet - Master seed / mnemonic (string) or raw seed bytes.
|
|
300
|
+
* Omit to connect without a wallet.
|
|
301
|
+
* @param walletOptions - Forwarded to {@link connectWallet}.
|
|
302
|
+
* @returns This connected Demos instance.
|
|
303
|
+
*/
|
|
304
|
+
async start(rpc_url, wallet, walletOptions) {
|
|
305
|
+
await this.connect(rpc_url);
|
|
306
|
+
if (wallet !== undefined) {
|
|
307
|
+
await this.connectWallet(wallet, walletOptions);
|
|
308
|
+
}
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Static one-call bootstrap over the shared singleton — starts
|
|
313
|
+
* {@link Demos.instance} and returns it ready for `demos.run.*`.
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* const demos = await Demos.start("https://node2.demos.sh", mnemonic)
|
|
318
|
+
* await demos.run.pay("0x...", 100n)
|
|
319
|
+
* ```
|
|
320
|
+
*
|
|
321
|
+
* @param rpc_url - The URL of the demos node.
|
|
322
|
+
* @param wallet - Master seed / mnemonic (string) or raw seed bytes.
|
|
323
|
+
* @param walletOptions - Forwarded to {@link connectWallet}.
|
|
324
|
+
* @returns The started shared Demos instance.
|
|
325
|
+
*/
|
|
326
|
+
static async start(rpc_url, wallet, walletOptions) {
|
|
327
|
+
return Demos.instance.start(rpc_url, wallet, walletOptions);
|
|
328
|
+
}
|
|
279
329
|
/**
|
|
280
330
|
* Connects to a Demos wallet using the provided master seed.
|
|
281
331
|
*
|
|
@@ -389,11 +439,11 @@ export class Demos {
|
|
|
389
439
|
* @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
|
|
390
440
|
* @returns The signed transaction.
|
|
391
441
|
*/
|
|
392
|
-
async pay(to, amount) {
|
|
442
|
+
async pay(to, amount, options) {
|
|
393
443
|
required(this.keypair, "Wallet not connected");
|
|
394
444
|
const amountOs = typeof amount === "bigint" ? amount : demToOs(amount);
|
|
395
445
|
await this._assertAmountAcceptableOnTargetNode(amountOs);
|
|
396
|
-
return DemosTransactions.pay(to, amountOs, this);
|
|
446
|
+
return DemosTransactions.pay(to, amountOs, this, options);
|
|
397
447
|
}
|
|
398
448
|
/**
|
|
399
449
|
* Create a signed DEMOS transaction to send native tokens to a given address.
|
|
@@ -412,8 +462,8 @@ export class Demos {
|
|
|
412
462
|
* @param amount - DEM `number` (legacy) or OS `bigint` (preferred).
|
|
413
463
|
* @returns The signed transaction.
|
|
414
464
|
*/
|
|
415
|
-
async transfer(to, amount) {
|
|
416
|
-
return this.pay(to, amount);
|
|
465
|
+
async transfer(to, amount, options) {
|
|
466
|
+
return this.pay(to, amount, options);
|
|
417
467
|
}
|
|
418
468
|
/**
|
|
419
469
|
* Create a signed DEMOS transaction to store binary data on the blockchain.
|
|
@@ -423,9 +473,9 @@ export class Demos {
|
|
|
423
473
|
*
|
|
424
474
|
* @returns The signed storage transaction.
|
|
425
475
|
*/
|
|
426
|
-
store(bytes) {
|
|
476
|
+
store(bytes, options) {
|
|
427
477
|
required(this.keypair, "Wallet not connected");
|
|
428
|
-
return DemosTransactions.store(bytes, this);
|
|
478
|
+
return DemosTransactions.store(bytes, this, options);
|
|
429
479
|
}
|
|
430
480
|
/**
|
|
431
481
|
* Confirms a transaction.
|
|
@@ -454,7 +504,7 @@ export class Demos {
|
|
|
454
504
|
* handle async confirmation yourself.
|
|
455
505
|
*
|
|
456
506
|
* @param validationData - The validity data of the transaction
|
|
457
|
-
* @param opts.timeoutMs - Total time to wait. Defaults to
|
|
507
|
+
* @param opts.timeoutMs - Total time to wait. Defaults to 60_000.
|
|
458
508
|
* @param opts.pollIntervalMs - Delay between polls. Defaults to 500.
|
|
459
509
|
*/
|
|
460
510
|
broadcastAndWait(validationData, opts) {
|
|
@@ -467,8 +517,11 @@ export class Demos {
|
|
|
467
517
|
* @param options - The dual-signing options
|
|
468
518
|
* @returns The signed transaction
|
|
469
519
|
*/
|
|
470
|
-
async sign(raw_tx) {
|
|
520
|
+
async sign(raw_tx, options) {
|
|
471
521
|
required(this.keypair, "Wallet not connected");
|
|
522
|
+
if (options?.nonce !== undefined) {
|
|
523
|
+
raw_tx.content.nonce = assertValidNonce(options.nonce);
|
|
524
|
+
}
|
|
472
525
|
if (!raw_tx.content.timestamp || raw_tx.content.timestamp === 0) {
|
|
473
526
|
raw_tx.content.timestamp = Date.now();
|
|
474
527
|
}
|
|
@@ -1417,6 +1470,42 @@ export class Demos {
|
|
|
1417
1470
|
}
|
|
1418
1471
|
return tlsn;
|
|
1419
1472
|
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Programmatic transaction facade — one call per transaction type.
|
|
1475
|
+
*
|
|
1476
|
+
* Collapses the classic `build → sign → confirm → broadcast` flow into a
|
|
1477
|
+
* single method per operation (`run.pay`, `run.attest.*`, `run.tokens.*`,
|
|
1478
|
+
* …) that auto-broadcasts within a configurable fee ceiling (default
|
|
1479
|
+
* 5 DEM). Additive: the classic `pay`/`confirm`/`broadcast` methods are
|
|
1480
|
+
* unchanged.
|
|
1481
|
+
*
|
|
1482
|
+
* Built lazily on first access (and memoised) rather than in the
|
|
1483
|
+
* constructor. Two reasons: (1) the singleton `demos = Demos.instance` is
|
|
1484
|
+
* created at import time, so eagerly *constructing* the namespaces during
|
|
1485
|
+
* `new Demos()` — which reach into `@/abstraction`, tokens, contracts — is
|
|
1486
|
+
* the part that risked tripping the websdk↔abstraction import cycle;
|
|
1487
|
+
* deferring construction removes that crash vector. (2) it avoids building
|
|
1488
|
+
* ~6 objects on every `new Demos()` that many callers never touch.
|
|
1489
|
+
*
|
|
1490
|
+
* Note: the programmatic module graph is still *loaded* when this file is
|
|
1491
|
+
* imported (a static `import` cannot be deferred in ESM). That residual
|
|
1492
|
+
* cycle is benign — no module reads a cross-cycle binding at evaluation
|
|
1493
|
+
* time, only inside functions — and has been narrowed by importing
|
|
1494
|
+
* `Identities` directly from `@/abstraction/Identities` rather than via the
|
|
1495
|
+
* `@/abstraction` barrel.
|
|
1496
|
+
*
|
|
1497
|
+
* @example
|
|
1498
|
+
* ```ts
|
|
1499
|
+
* // one-call payment, auto-broadcast within the 5 DEM fee cap
|
|
1500
|
+
* await demos.run.pay("0x...", 100n)
|
|
1501
|
+
* // build + confirm only, broadcast yourself later
|
|
1502
|
+
* const r = await demos.run.pay("0x...", 100n, { confirm: "manual" })
|
|
1503
|
+
* await demos.broadcast(r.validityData)
|
|
1504
|
+
* ```
|
|
1505
|
+
*/
|
|
1506
|
+
get run() {
|
|
1507
|
+
return (this._run ?? (this._run = createProgrammaticTx(this)));
|
|
1508
|
+
}
|
|
1420
1509
|
}
|
|
1421
1510
|
Demos._instance = null;
|
|
1422
1511
|
/**
|