@arcadiasystems/morse-sdk 0.1.0
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/CHANGELOG.md +35 -0
- package/LICENSE +21 -0
- package/README.md +404 -0
- package/dist/clients.d.ts +12 -0
- package/dist/clients.d.ts.map +1 -0
- package/dist/clients.js +6 -0
- package/dist/clients.js.map +1 -0
- package/dist/codecs.d.ts +45 -0
- package/dist/codecs.d.ts.map +1 -0
- package/dist/codecs.js +132 -0
- package/dist/codecs.js.map +1 -0
- package/dist/compatibility.d.ts +22 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +22 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +85 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +101 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +214 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/ops/cap.d.ts +79 -0
- package/dist/ops/cap.d.ts.map +1 -0
- package/dist/ops/cap.js +104 -0
- package/dist/ops/cap.js.map +1 -0
- package/dist/ops/collection.d.ts +50 -0
- package/dist/ops/collection.d.ts.map +1 -0
- package/dist/ops/collection.js +55 -0
- package/dist/ops/collection.js.map +1 -0
- package/dist/ops/entry-from-bytes.d.ts +129 -0
- package/dist/ops/entry-from-bytes.d.ts.map +1 -0
- package/dist/ops/entry-from-bytes.js +137 -0
- package/dist/ops/entry-from-bytes.js.map +1 -0
- package/dist/ops/entry.d.ts +173 -0
- package/dist/ops/entry.d.ts.map +1 -0
- package/dist/ops/entry.js +235 -0
- package/dist/ops/entry.js.map +1 -0
- package/dist/ops/index.d.ts +9 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +9 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/internal.d.ts +21 -0
- package/dist/ops/internal.d.ts.map +1 -0
- package/dist/ops/internal.js +42 -0
- package/dist/ops/internal.js.map +1 -0
- package/dist/ops/publication.d.ts +74 -0
- package/dist/ops/publication.d.ts.map +1 -0
- package/dist/ops/publication.js +123 -0
- package/dist/ops/publication.js.map +1 -0
- package/dist/ptb/cap.d.ts +36 -0
- package/dist/ptb/cap.d.ts.map +1 -0
- package/dist/ptb/cap.js +44 -0
- package/dist/ptb/cap.js.map +1 -0
- package/dist/ptb/collection.d.ts +27 -0
- package/dist/ptb/collection.d.ts.map +1 -0
- package/dist/ptb/collection.js +33 -0
- package/dist/ptb/collection.js.map +1 -0
- package/dist/ptb/entry.d.ts +104 -0
- package/dist/ptb/entry.d.ts.map +1 -0
- package/dist/ptb/entry.js +155 -0
- package/dist/ptb/entry.js.map +1 -0
- package/dist/ptb/index.d.ts +9 -0
- package/dist/ptb/index.d.ts.map +1 -0
- package/dist/ptb/index.js +9 -0
- package/dist/ptb/index.js.map +1 -0
- package/dist/ptb/internal.d.ts +11 -0
- package/dist/ptb/internal.d.ts.map +1 -0
- package/dist/ptb/internal.js +12 -0
- package/dist/ptb/internal.js.map +1 -0
- package/dist/ptb/publication.d.ts +51 -0
- package/dist/ptb/publication.d.ts.map +1 -0
- package/dist/ptb/publication.js +61 -0
- package/dist/ptb/publication.js.map +1 -0
- package/dist/read/entry-bcs.d.ts +47 -0
- package/dist/read/entry-bcs.d.ts.map +1 -0
- package/dist/read/entry-bcs.js +36 -0
- package/dist/read/entry-bcs.js.map +1 -0
- package/dist/read/index.d.ts +5 -0
- package/dist/read/index.d.ts.map +1 -0
- package/dist/read/index.js +5 -0
- package/dist/read/index.js.map +1 -0
- package/dist/read/reader.d.ts +148 -0
- package/dist/read/reader.d.ts.map +1 -0
- package/dist/read/reader.js +403 -0
- package/dist/read/reader.js.map +1 -0
- package/dist/seal/adapter.d.ts +56 -0
- package/dist/seal/adapter.d.ts.map +1 -0
- package/dist/seal/adapter.js +7 -0
- package/dist/seal/adapter.js.map +1 -0
- package/dist/seal/default-adapter.d.ts +90 -0
- package/dist/seal/default-adapter.d.ts.map +1 -0
- package/dist/seal/default-adapter.js +187 -0
- package/dist/seal/default-adapter.js.map +1 -0
- package/dist/seal/identity.d.ts +31 -0
- package/dist/seal/identity.d.ts.map +1 -0
- package/dist/seal/identity.js +79 -0
- package/dist/seal/identity.js.map +1 -0
- package/dist/seal/index.d.ts +8 -0
- package/dist/seal/index.d.ts.map +1 -0
- package/dist/seal/index.js +7 -0
- package/dist/seal/index.js.map +1 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +33 -0
- package/dist/types.js.map +1 -0
- package/dist/wallets/adapter.d.ts +34 -0
- package/dist/wallets/adapter.d.ts.map +1 -0
- package/dist/wallets/adapter.js +6 -0
- package/dist/wallets/adapter.js.map +1 -0
- package/dist/wallets/index.d.ts +7 -0
- package/dist/wallets/index.d.ts.map +1 -0
- package/dist/wallets/index.js +6 -0
- package/dist/wallets/index.js.map +1 -0
- package/dist/wallets/keypair-adapter.d.ts +31 -0
- package/dist/wallets/keypair-adapter.d.ts.map +1 -0
- package/dist/wallets/keypair-adapter.js +210 -0
- package/dist/wallets/keypair-adapter.js.map +1 -0
- package/dist/wallets/wallet-standard-signer.d.ts +118 -0
- package/dist/wallets/wallet-standard-signer.d.ts.map +1 -0
- package/dist/wallets/wallet-standard-signer.js +207 -0
- package/dist/wallets/wallet-standard-signer.js.map +1 -0
- package/dist/walrus/adapter.d.ts +91 -0
- package/dist/walrus/adapter.d.ts.map +1 -0
- package/dist/walrus/adapter.js +11 -0
- package/dist/walrus/adapter.js.map +1 -0
- package/dist/walrus/default-adapter.d.ts +104 -0
- package/dist/walrus/default-adapter.d.ts.map +1 -0
- package/dist/walrus/default-adapter.js +146 -0
- package/dist/walrus/default-adapter.js.map +1 -0
- package/dist/walrus/default-read-adapter.d.ts +89 -0
- package/dist/walrus/default-read-adapter.d.ts.map +1 -0
- package/dist/walrus/default-read-adapter.js +81 -0
- package/dist/walrus/default-read-adapter.js.map +1 -0
- package/dist/walrus/http-aggregator-read-adapter.d.ts +107 -0
- package/dist/walrus/http-aggregator-read-adapter.d.ts.map +1 -0
- package/dist/walrus/http-aggregator-read-adapter.js +174 -0
- package/dist/walrus/http-aggregator-read-adapter.js.map +1 -0
- package/dist/walrus/http-publisher-write-adapter.d.ts +97 -0
- package/dist/walrus/http-publisher-write-adapter.d.ts.map +1 -0
- package/dist/walrus/http-publisher-write-adapter.js +249 -0
- package/dist/walrus/http-publisher-write-adapter.js.map +1 -0
- package/dist/walrus/index.d.ts +11 -0
- package/dist/walrus/index.d.ts.map +1 -0
- package/dist/walrus/index.js +11 -0
- package/dist/walrus/index.js.map +1 -0
- package/dist/walrus/quilt-patch-id.d.ts +34 -0
- package/dist/walrus/quilt-patch-id.d.ts.map +1 -0
- package/dist/walrus/quilt-patch-id.js +103 -0
- package/dist/walrus/quilt-patch-id.js.map +1 -0
- package/package.json +72 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public domain types, mirroring `morse-contracts`.
|
|
3
|
+
*
|
|
4
|
+
* Mapping conventions: Move `u64` to `number`; Move `Option<T>` to `T | null`;
|
|
5
|
+
* Move enums to string-discriminated unions; object IDs are branded strings.
|
|
6
|
+
*/
|
|
7
|
+
// Storage mode
|
|
8
|
+
/**
|
|
9
|
+
* Collection content layout on Walrus: standalone blobs per entry (`blob`, u8=0)
|
|
10
|
+
* or patches in a shared quilt (`quilt`, u8=1).
|
|
11
|
+
*/
|
|
12
|
+
export const StorageMode = {
|
|
13
|
+
Blob: "blob",
|
|
14
|
+
Quilt: "quilt",
|
|
15
|
+
};
|
|
16
|
+
// Access policy
|
|
17
|
+
/**
|
|
18
|
+
* Who may decrypt an entry revision. Move u8: public=0, publisher=1, subscription=2.
|
|
19
|
+
* `subscription` is reserved; the Move layer does not yet accept it.
|
|
20
|
+
*/
|
|
21
|
+
export const AccessPolicy = {
|
|
22
|
+
Public: "public",
|
|
23
|
+
Publisher: "publisher",
|
|
24
|
+
Subscription: "subscription",
|
|
25
|
+
};
|
|
26
|
+
// Seal policy tag
|
|
27
|
+
/** Policy tag byte inside a Seal identity, identifying the approval entrypoint. */
|
|
28
|
+
export const SealPolicyTag = {
|
|
29
|
+
Publisher: 1,
|
|
30
|
+
};
|
|
31
|
+
/** Byte length of a QuiltPatchId, enforced by the Move layer. */
|
|
32
|
+
export const QUILT_PATCH_ID_LENGTH = 37;
|
|
33
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmDH,eAAe;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IAC1B,IAAI,EAAE,MAAM;IACZ,KAAK,EAAE,OAAO;CACL,CAAC;AAGX,gBAAgB;AAEhB;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;CACnB,CAAC;AAGX,kBAAkB;AAElB,mFAAmF;AACnF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC5B,SAAS,EAAE,CAAC;CACH,CAAC;AAaX,iEAAiE;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet adapter interface. The SDK signs through implementations of this type,
|
|
3
|
+
* never touching private keys directly.
|
|
4
|
+
*/
|
|
5
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
6
|
+
import type { SuiAddress, TxReceipt } from "../types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Per-command return values from a simulated PTB. Outer index is the command
|
|
9
|
+
* (in order added to the `Transaction`); inner index is the return value of
|
|
10
|
+
* that command. Each value is BCS-encoded; decode with the matching
|
|
11
|
+
* `@mysten/bcs` schema.
|
|
12
|
+
*/
|
|
13
|
+
export type SimulationReturnValues = ReadonlyArray<readonly Uint8Array[]>;
|
|
14
|
+
/** Signs and submits Move transactions on behalf of a single Sui account. */
|
|
15
|
+
export interface WalletAdapter {
|
|
16
|
+
/** Active account at adapter construction time; switching requires a new instance. */
|
|
17
|
+
readonly address: SuiAddress;
|
|
18
|
+
/**
|
|
19
|
+
* Sign, submit, and await finality.
|
|
20
|
+
* @throws {ContractAbortError} On Move abort.
|
|
21
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
22
|
+
*/
|
|
23
|
+
signAndExecuteTransaction(tx: Transaction, signal?: AbortSignal): Promise<TxReceipt>;
|
|
24
|
+
/**
|
|
25
|
+
* Dry-run a PTB and return per-command BCS-encoded return values. Used by
|
|
26
|
+
* ops that need values returned by Move calls (no other path on Sui without
|
|
27
|
+
* a contract upgrade for events). Subject to a snapshot-vs-execute race for
|
|
28
|
+
* shared-object reads; acceptable for single-publisher write paths.
|
|
29
|
+
* @throws {ContractAbortError} On simulated Move abort.
|
|
30
|
+
* @throws {TransportError} On RPC, network, or response-parsing failure.
|
|
31
|
+
*/
|
|
32
|
+
simulateTransaction(tx: Transaction, signal?: AbortSignal): Promise<SimulationReturnValues>;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../src/wallets/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG,aAAa,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC;AAE1E,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC7B,sFAAsF;IACtF,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAE7B;;;;OAIG;IACH,yBAAyB,CACxB,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,SAAS,CAAC,CAAC;IAEtB;;;;;;;OAOG;IACH,mBAAmB,CAClB,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../src/wallets/adapter.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public barrel for the wallet adapter layer.
|
|
3
|
+
*/
|
|
4
|
+
export type { SimulationReturnValues, WalletAdapter } from "./adapter.js";
|
|
5
|
+
export { KeypairAdapter } from "./keypair-adapter.js";
|
|
6
|
+
export { type WalletSignPersonalMessage, type WalletSignTransaction, type WalletStandardAccount, WalletStandardSigner, type WalletStandardSignerCallbacks, type WalletStandardSignerOptions, } from "./wallet-standard-signer.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACN,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,oBAAoB,EACpB,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,GAChC,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAIN,oBAAoB,GAGpB,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet adapter that signs with a local Sui keypair. Suitable for servers,
|
|
3
|
+
* CLIs, scripts, and tests; not suitable for browser apps that should defer
|
|
4
|
+
* signing to a user-controlled wallet.
|
|
5
|
+
*/
|
|
6
|
+
import type { Signer } from "@mysten/sui/cryptography";
|
|
7
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
8
|
+
import type { TransactionExecutor } from "../clients.js";
|
|
9
|
+
import type { SuiAddress, TxReceipt } from "../types.js";
|
|
10
|
+
import type { SimulationReturnValues, WalletAdapter } from "./adapter.js";
|
|
11
|
+
/**
|
|
12
|
+
* Wallet adapter wrapping a `@mysten/sui` `Signer` (any keypair) plus a
|
|
13
|
+
* narrow client. Submits transactions, normalizes effects into a `TxReceipt`,
|
|
14
|
+
* and maps Move aborts to `ContractAbortError`.
|
|
15
|
+
*/
|
|
16
|
+
export declare class KeypairAdapter implements WalletAdapter {
|
|
17
|
+
private readonly signer;
|
|
18
|
+
private readonly client;
|
|
19
|
+
readonly address: SuiAddress;
|
|
20
|
+
constructor(signer: Signer, client: TransactionExecutor);
|
|
21
|
+
/**
|
|
22
|
+
* Construct from a raw secret key (Bech32 string or 32-byte `Uint8Array`).
|
|
23
|
+
* Convenience for CLIs and scripts; uses Ed25519.
|
|
24
|
+
*/
|
|
25
|
+
static fromSecretKey(secretKey: Uint8Array | string, client: TransactionExecutor): KeypairAdapter;
|
|
26
|
+
signAndExecuteTransaction(tx: Transaction, signal?: AbortSignal): Promise<TxReceipt>;
|
|
27
|
+
simulateTransaction(tx: Transaction, signal?: AbortSignal): Promise<SimulationReturnValues>;
|
|
28
|
+
private submit;
|
|
29
|
+
private waitForFinality;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=keypair-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keypair-adapter.d.ts","sourceRoot":"","sources":["../../src/wallets/keypair-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAOzD,OAAO,KAAK,EACX,UAAU,EAGV,SAAS,EACT,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAoB1E;;;;GAIG;AACH,qBAAa,cAAe,YAAW,aAAa;IAIlD,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJxB,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;gBAGX,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB;IAK7C;;;OAGG;IACH,MAAM,CAAC,aAAa,CACnB,SAAS,EAAE,UAAU,GAAG,MAAM,EAC9B,MAAM,EAAE,mBAAmB,GACzB,cAAc;IAIX,yBAAyB,CAC9B,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,SAAS,CAAC;IAMf,mBAAmB,CACxB,EAAE,EAAE,WAAW,EACf,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,sBAAsB,CAAC;YAkBpB,MAAM;YAkBN,eAAe;CAgB7B"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wallet adapter that signs with a local Sui keypair. Suitable for servers,
|
|
3
|
+
* CLIs, scripts, and tests; not suitable for browser apps that should defer
|
|
4
|
+
* signing to a user-controlled wallet.
|
|
5
|
+
*/
|
|
6
|
+
import { SimulationError } from "@mysten/sui/client";
|
|
7
|
+
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
|
|
8
|
+
import { toSuiAddress, toSuiObjectId } from "../codecs.js";
|
|
9
|
+
import { ContractAbortError, TransportError, } from "../errors.js";
|
|
10
|
+
const TX_INCLUDE = { effects: true, objectTypes: true };
|
|
11
|
+
const SIM_INCLUDE = { effects: true, commandResults: true };
|
|
12
|
+
const KNOWN_ABORT_MODULES = new Set([
|
|
13
|
+
"publication",
|
|
14
|
+
"collection",
|
|
15
|
+
"entry",
|
|
16
|
+
]);
|
|
17
|
+
/**
|
|
18
|
+
* Wallet adapter wrapping a `@mysten/sui` `Signer` (any keypair) plus a
|
|
19
|
+
* narrow client. Submits transactions, normalizes effects into a `TxReceipt`,
|
|
20
|
+
* and maps Move aborts to `ContractAbortError`.
|
|
21
|
+
*/
|
|
22
|
+
export class KeypairAdapter {
|
|
23
|
+
signer;
|
|
24
|
+
client;
|
|
25
|
+
address;
|
|
26
|
+
constructor(signer, client) {
|
|
27
|
+
this.signer = signer;
|
|
28
|
+
this.client = client;
|
|
29
|
+
this.address = toSuiAddress(signer.toSuiAddress());
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Construct from a raw secret key (Bech32 string or 32-byte `Uint8Array`).
|
|
33
|
+
* Convenience for CLIs and scripts; uses Ed25519.
|
|
34
|
+
*/
|
|
35
|
+
static fromSecretKey(secretKey, client) {
|
|
36
|
+
return new KeypairAdapter(Ed25519Keypair.fromSecretKey(secretKey), client);
|
|
37
|
+
}
|
|
38
|
+
async signAndExecuteTransaction(tx, signal) {
|
|
39
|
+
const submitted = await this.submit(tx, signal);
|
|
40
|
+
const final = await this.waitForFinality(submitted, signal);
|
|
41
|
+
return parseReceipt(final);
|
|
42
|
+
}
|
|
43
|
+
async simulateTransaction(tx, signal) {
|
|
44
|
+
// `signAndExecuteTransaction` derives the sender from `signer`; the
|
|
45
|
+
// simulate path does not, so callers would otherwise get a zero-address
|
|
46
|
+
// sender and the simulator would reject any owned-object references.
|
|
47
|
+
tx.setSenderIfNotSet(this.address);
|
|
48
|
+
const result = await callClient("simulateTransaction", () => this.client.simulateTransaction({
|
|
49
|
+
transaction: tx,
|
|
50
|
+
include: SIM_INCLUDE,
|
|
51
|
+
...(signal === undefined ? {} : { signal }),
|
|
52
|
+
}));
|
|
53
|
+
if (result.$kind === "FailedTransaction") {
|
|
54
|
+
throw mapFailedTransaction(result.FailedTransaction);
|
|
55
|
+
}
|
|
56
|
+
return parseSimulationReturnValues(result);
|
|
57
|
+
}
|
|
58
|
+
async submit(tx, signal) {
|
|
59
|
+
const result = await callClient("signAndExecuteTransaction", () => this.client.signAndExecuteTransaction({
|
|
60
|
+
signer: this.signer,
|
|
61
|
+
transaction: tx,
|
|
62
|
+
include: TX_INCLUDE,
|
|
63
|
+
...(signal === undefined ? {} : { signal }),
|
|
64
|
+
}));
|
|
65
|
+
if (result.$kind === "FailedTransaction") {
|
|
66
|
+
throw mapFailedTransaction(result.FailedTransaction);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
async waitForFinality(submitted, signal) {
|
|
71
|
+
const final = await callClient("waitForTransaction", () => this.client.waitForTransaction({
|
|
72
|
+
result: submitted,
|
|
73
|
+
include: TX_INCLUDE,
|
|
74
|
+
...(signal === undefined ? {} : { signal }),
|
|
75
|
+
}));
|
|
76
|
+
if (final.$kind === "FailedTransaction") {
|
|
77
|
+
throw mapFailedTransaction(final.FailedTransaction);
|
|
78
|
+
}
|
|
79
|
+
return final;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function callClient(operation, call) {
|
|
83
|
+
try {
|
|
84
|
+
return await call();
|
|
85
|
+
}
|
|
86
|
+
catch (cause) {
|
|
87
|
+
const mapped = tryMapSimulationAbort(cause);
|
|
88
|
+
if (mapped) {
|
|
89
|
+
throw mapped;
|
|
90
|
+
}
|
|
91
|
+
throw new TransportError(`${operation} failed`, { cause });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The Sui gRPC client throws `SimulationError` when the transaction's pre-submit
|
|
96
|
+
* dry-run hits a Move abort. The error carries an `executionError` with a
|
|
97
|
+
* structured `MoveAbort`. Detect that and map to `ContractAbortError`; return
|
|
98
|
+
* `null` for any other failure so the caller falls back to `TransportError`.
|
|
99
|
+
*/
|
|
100
|
+
function tryMapSimulationAbort(cause) {
|
|
101
|
+
if (!(cause instanceof SimulationError)) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const executionError = cause.executionError;
|
|
105
|
+
if (!executionError) {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
const moveAbort = executionError.MoveAbort;
|
|
109
|
+
if (!moveAbort) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return mapMoveAbortToContractAbortError(moveAbort);
|
|
113
|
+
}
|
|
114
|
+
function parseReceipt(final) {
|
|
115
|
+
if (final.$kind !== "Transaction") {
|
|
116
|
+
throw new TransportError("Transaction result missing after waitForTransaction");
|
|
117
|
+
}
|
|
118
|
+
const tx = final.Transaction;
|
|
119
|
+
const effects = tx.effects;
|
|
120
|
+
if (!effects) {
|
|
121
|
+
throw new TransportError("Transaction effects missing; client did not return them despite include flag");
|
|
122
|
+
}
|
|
123
|
+
const objectTypes = tx.objectTypes ?? {};
|
|
124
|
+
return {
|
|
125
|
+
digest: tx.digest,
|
|
126
|
+
gasUsedMist: computeGasUsedMist(effects.gasUsed),
|
|
127
|
+
createdObjects: collectCreated(effects.changedObjects, objectTypes),
|
|
128
|
+
deletedObjects: collectDeleted(effects.changedObjects),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function computeGasUsedMist(gas) {
|
|
132
|
+
return (BigInt(gas.computationCost) +
|
|
133
|
+
BigInt(gas.storageCost) -
|
|
134
|
+
BigInt(gas.storageRebate));
|
|
135
|
+
}
|
|
136
|
+
function collectCreated(changes, objectTypes) {
|
|
137
|
+
const out = [];
|
|
138
|
+
for (const change of changes) {
|
|
139
|
+
if (change.idOperation !== "Created") {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
// Sui occasionally lists Created entries without type info (internal
|
|
143
|
+
// or auxiliary objects). Skip those: the array only carries entries
|
|
144
|
+
// the SDK can identify by type. Missing-by-type lookups surface
|
|
145
|
+
// downstream via findCreatedId.
|
|
146
|
+
const objectType = objectTypes[change.objectId];
|
|
147
|
+
if (objectType === undefined) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
out.push({
|
|
151
|
+
objectId: toSuiObjectId(change.objectId),
|
|
152
|
+
objectType,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
function collectDeleted(changes) {
|
|
158
|
+
const out = [];
|
|
159
|
+
for (const change of changes) {
|
|
160
|
+
if (change.idOperation !== "Deleted") {
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
out.push({ objectId: toSuiObjectId(change.objectId) });
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
function mapFailedTransaction(failed) {
|
|
168
|
+
const status = failed.effects?.status;
|
|
169
|
+
if (status && !status.success) {
|
|
170
|
+
const moveAbort = status.error.MoveAbort;
|
|
171
|
+
if (moveAbort) {
|
|
172
|
+
const mapped = mapMoveAbortToContractAbortError(moveAbort);
|
|
173
|
+
if (mapped) {
|
|
174
|
+
return mapped;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return new TransportError(`Transaction execution failed: ${status.error.message}`);
|
|
178
|
+
}
|
|
179
|
+
return new TransportError("Transaction failed without effects status");
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Map a `MoveAbort` proto shape (from either a SimulationError's
|
|
183
|
+
* `executionError` or a FailedTransaction's `effects.status.error`) to a
|
|
184
|
+
* `ContractAbortError`, or `null` if the module is not one this SDK recognizes
|
|
185
|
+
* or the abort code is malformed. Callers fall back to `TransportError` on `null`.
|
|
186
|
+
*/
|
|
187
|
+
function mapMoveAbortToContractAbortError(moveAbort) {
|
|
188
|
+
const moduleName = moveAbort.location?.module;
|
|
189
|
+
const code = Number(moveAbort.abortCode);
|
|
190
|
+
if (moduleName !== undefined &&
|
|
191
|
+
isKnownAbortModule(moduleName) &&
|
|
192
|
+
Number.isFinite(code)) {
|
|
193
|
+
return ContractAbortError.fromAbortCode(moduleName, code);
|
|
194
|
+
}
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
function isKnownAbortModule(name) {
|
|
198
|
+
return KNOWN_ABORT_MODULES.has(name);
|
|
199
|
+
}
|
|
200
|
+
function parseSimulationReturnValues(result) {
|
|
201
|
+
if (result.$kind !== "Transaction") {
|
|
202
|
+
throw new TransportError("Simulate did not return a Transaction result");
|
|
203
|
+
}
|
|
204
|
+
const commandResults = result.commandResults;
|
|
205
|
+
if (!commandResults) {
|
|
206
|
+
throw new TransportError("Simulation result missing commandResults despite include flag");
|
|
207
|
+
}
|
|
208
|
+
return commandResults.map((cmd) => cmd.returnValues.map((rv) => rv.bcs));
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=keypair-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keypair-adapter.js","sourceRoot":"","sources":["../../src/wallets/keypair-adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,eAAe,EAAuB,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAEN,kBAAkB,EAClB,cAAc,GACd,MAAM,cAAc,CAAC;AAiBtB,MAAM,UAAU,GAAc,EAAE,OAAO,EAAE,IA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AC,IAAmB,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,2BAA2B,CACnC,MAAiB;IAEjB,IAAI,MAAM,CAAC,KAAK,KAAK,aAAa,EAAE,CAAC;QACpC,MAAM,IAAI,cAAc,CAAC,8CAA8C,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,CAAC;IAC7C,IAAI,CAAC,cAAc,EAAE,CAAC;QACrB,MAAM,IAAI,cAAc,CACvB,+DAA+D,CAC/D,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Signer` subclass that delegates signing to a wallet-standard wallet
|
|
3
|
+
* (Suiet, Sui Wallet, Slush, etc.) via the dapp-kit hooks `useSignTransaction`
|
|
4
|
+
* and `useSignPersonalMessage`. The user's private key never leaves the
|
|
5
|
+
* wallet.
|
|
6
|
+
*
|
|
7
|
+
* Use this when passing a signer to libraries that accept the Sui
|
|
8
|
+
* `@mysten/sui/cryptography` `Signer` abstract — `@mysten/walrus`'s
|
|
9
|
+
* `WalrusClient.writeBlob({ signer })` and `@mysten/seal`'s
|
|
10
|
+
* `SessionKey.create({ signer })`.
|
|
11
|
+
*
|
|
12
|
+
* Methods called by Walrus on the signer: `toSuiAddress`,
|
|
13
|
+
* `signAndExecuteTransaction({ transaction, client })`. Methods called by
|
|
14
|
+
* Seal: `getPublicKey().toSuiAddress()`, `signPersonalMessage(bytes)`. The
|
|
15
|
+
* `sign(bytes)` raw-byte primitive is intentionally not implemented;
|
|
16
|
+
* wallets do not expose raw signing for security reasons. If a future
|
|
17
|
+
* library version invokes `sign(bytes)` or `signTransaction(bytes)`
|
|
18
|
+
* directly (raw-byte form, not the override), this signer throws.
|
|
19
|
+
*/
|
|
20
|
+
import type { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
|
|
21
|
+
import { type PublicKey, type SignatureScheme, type SignatureWithBytes, Signer } from "@mysten/sui/cryptography";
|
|
22
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
23
|
+
/**
|
|
24
|
+
* Callback shape returned by dapp-kit's `useSignTransaction.mutateAsync`.
|
|
25
|
+
* The wallet signs and returns the canonical BCS-serialized transaction
|
|
26
|
+
* bytes (base64-encoded) plus the signature; it does not submit.
|
|
27
|
+
*/
|
|
28
|
+
export type WalletSignTransaction = (input: {
|
|
29
|
+
transaction: Transaction;
|
|
30
|
+
}) => Promise<SignatureWithBytes>;
|
|
31
|
+
/**
|
|
32
|
+
* Callback shape returned by dapp-kit's `useSignPersonalMessage.mutateAsync`.
|
|
33
|
+
* The wallet signs the personal message and returns the original message
|
|
34
|
+
* bytes (base64-encoded by the wallet) plus the signature.
|
|
35
|
+
*/
|
|
36
|
+
export type WalletSignPersonalMessage = (input: {
|
|
37
|
+
message: Uint8Array;
|
|
38
|
+
}) => Promise<{
|
|
39
|
+
bytes: string;
|
|
40
|
+
signature: string;
|
|
41
|
+
}>;
|
|
42
|
+
export interface WalletStandardSignerOptions {
|
|
43
|
+
readonly publicKey: PublicKey;
|
|
44
|
+
readonly keyScheme: SignatureScheme;
|
|
45
|
+
readonly signTransaction: WalletSignTransaction;
|
|
46
|
+
readonly signPersonalMessage: WalletSignPersonalMessage;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Minimal `WalletAccount` shape consumed by `WalletStandardSigner.fromAccount`.
|
|
50
|
+
* Structurally compatible with `WalletAccount` from `@wallet-standard/base`
|
|
51
|
+
* and `@mysten/wallet-standard`. Defined locally so morse-sdk does not have
|
|
52
|
+
* to take a peer dependency just for this interface.
|
|
53
|
+
*/
|
|
54
|
+
export interface WalletStandardAccount {
|
|
55
|
+
readonly address: string;
|
|
56
|
+
readonly publicKey: ArrayLike<number>;
|
|
57
|
+
}
|
|
58
|
+
/** Callback bundle paired with a `WalletStandardAccount` in `fromAccount`. */
|
|
59
|
+
export interface WalletStandardSignerCallbacks {
|
|
60
|
+
readonly signTransaction: WalletSignTransaction;
|
|
61
|
+
readonly signPersonalMessage: WalletSignPersonalMessage;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `Signer` backed by wallet-standard callbacks. Supplies methods Walrus and
|
|
65
|
+
* Seal call; throws on raw-byte signing, which wallets do not expose.
|
|
66
|
+
*/
|
|
67
|
+
export declare class WalletStandardSigner extends Signer {
|
|
68
|
+
#private;
|
|
69
|
+
constructor(options: WalletStandardSignerOptions);
|
|
70
|
+
/**
|
|
71
|
+
* Build a signer from a wallet-standard `WalletAccount` plus the wallet's
|
|
72
|
+
* `signTransaction` / `signPersonalMessage` callbacks. Tries every plausible
|
|
73
|
+
* interpretation of `account.publicKey` and returns the one whose derived
|
|
74
|
+
* address matches `account.address`.
|
|
75
|
+
*
|
|
76
|
+
* Wallet-standard does not mandate a single encoding for `publicKey`:
|
|
77
|
+
* Suiet emits raw bytes (e.g. 32 for Ed25519), Slush emits Sui's canonical
|
|
78
|
+
* with-flag form (e.g. `0x00 || 32-byte raw` for Ed25519). Both are
|
|
79
|
+
* accepted; address-match disambiguates.
|
|
80
|
+
*
|
|
81
|
+
* Supported schemes: ED25519, Secp256k1, Secp256r1, Passkey (raw or
|
|
82
|
+
* flag-prefixed), and ZkLogin (variable-length identifier of the form
|
|
83
|
+
* `[1 byte iss-len][iss bytes][32 byte addressSeed]`). MultiSig is
|
|
84
|
+
* refused.
|
|
85
|
+
*
|
|
86
|
+
* Caveat for ZkLogin: the dispatch is structurally correct but
|
|
87
|
+
* end-to-end behavior against `@mysten/walrus`'s `register_blob` /
|
|
88
|
+
* `certify_blob` and `@mysten/seal`'s `SessionKey` verification has
|
|
89
|
+
* not been smoke-tested. If your users see Seal `decrypt-failed` or
|
|
90
|
+
* Walrus signature errors on zkLogin accounts, fall back to a
|
|
91
|
+
* keypair account.
|
|
92
|
+
*
|
|
93
|
+
* @throws {ConfigurationError} If the account uses multisig, or if no
|
|
94
|
+
* candidate scheme produces an address matching `account.address`.
|
|
95
|
+
*/
|
|
96
|
+
static fromAccount(account: WalletStandardAccount, callbacks: WalletStandardSignerCallbacks): WalletStandardSigner;
|
|
97
|
+
getKeyScheme(): SignatureScheme;
|
|
98
|
+
getPublicKey(): PublicKey;
|
|
99
|
+
sign(_bytes: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
|
|
100
|
+
signPersonalMessage(message: Uint8Array): Promise<{
|
|
101
|
+
bytes: string;
|
|
102
|
+
signature: string;
|
|
103
|
+
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Sign and submit a transaction. The wallet pops up to confirm; on approval
|
|
106
|
+
* it returns canonical BCS bytes plus signature. Those bytes (not any
|
|
107
|
+
* locally-built bytes) are submitted via the supplied client so the
|
|
108
|
+
* signature validates against what the wallet actually signed.
|
|
109
|
+
*/
|
|
110
|
+
signAndExecuteTransaction({ transaction, client, }: {
|
|
111
|
+
transaction: Transaction;
|
|
112
|
+
client: ClientWithCoreApi;
|
|
113
|
+
}): Promise<SuiClientTypes.TransactionResult<{
|
|
114
|
+
transaction: true;
|
|
115
|
+
effects: true;
|
|
116
|
+
}>>;
|
|
117
|
+
}
|
|
118
|
+
//# sourceMappingURL=wallet-standard-signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wallet-standard-signer.d.ts","sourceRoot":"","sources":["../../src/wallets/wallet-standard-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACN,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,MAAM,EACN,MAAM,0BAA0B,CAAC;AAK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