@haneullabs/wallet-standard 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 +1438 -0
- package/README.md +6 -0
- package/dist/cjs/chains.d.ts +16 -0
- package/dist/cjs/chains.js +42 -0
- package/dist/cjs/chains.js.map +7 -0
- package/dist/cjs/detect.d.ts +3 -0
- package/dist/cjs/detect.js +31 -0
- package/dist/cjs/detect.js.map +7 -0
- package/dist/cjs/features/haneulGetCapabilities.d.ts +15 -0
- package/dist/cjs/features/haneulGetCapabilities.js +25 -0
- package/dist/cjs/features/haneulGetCapabilities.js.map +7 -0
- package/dist/cjs/features/haneulReportTransactionEffects.d.ts +26 -0
- package/dist/cjs/features/haneulReportTransactionEffects.js +25 -0
- package/dist/cjs/features/haneulReportTransactionEffects.js.map +7 -0
- package/dist/cjs/features/haneulSignAndExecuteTransaction.d.ts +28 -0
- package/dist/cjs/features/haneulSignAndExecuteTransaction.js +25 -0
- package/dist/cjs/features/haneulSignAndExecuteTransaction.js.map +7 -0
- package/dist/cjs/features/haneulSignAndExecuteTransactionBlock.d.ts +36 -0
- package/dist/cjs/features/haneulSignAndExecuteTransactionBlock.js +25 -0
- package/dist/cjs/features/haneulSignAndExecuteTransactionBlock.js.map +7 -0
- package/dist/cjs/features/haneulSignMessage.d.ts +45 -0
- package/dist/cjs/features/haneulSignMessage.js +25 -0
- package/dist/cjs/features/haneulSignMessage.js.map +7 -0
- package/dist/cjs/features/haneulSignPersonalMessage.d.ts +33 -0
- package/dist/cjs/features/haneulSignPersonalMessage.js +25 -0
- package/dist/cjs/features/haneulSignPersonalMessage.js.map +7 -0
- package/dist/cjs/features/haneulSignTransaction.d.ts +34 -0
- package/dist/cjs/features/haneulSignTransaction.js +25 -0
- package/dist/cjs/features/haneulSignTransaction.js.map +7 -0
- package/dist/cjs/features/haneulSignTransactionBlock.d.ts +38 -0
- package/dist/cjs/features/haneulSignTransactionBlock.js +25 -0
- package/dist/cjs/features/haneulSignTransactionBlock.js.map +7 -0
- package/dist/cjs/features/index.d.ts +28 -0
- package/dist/cjs/features/index.js +26 -0
- package/dist/cjs/features/index.js.map +7 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +32 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +5 -0
- package/dist/cjs/types.d.ts +159 -0
- package/dist/cjs/types.js +17 -0
- package/dist/cjs/types.js.map +7 -0
- package/dist/cjs/wallet.d.ts +18 -0
- package/dist/cjs/wallet.js +80 -0
- package/dist/cjs/wallet.js.map +7 -0
- package/dist/esm/chains.d.ts +16 -0
- package/dist/esm/chains.js +22 -0
- package/dist/esm/chains.js.map +7 -0
- package/dist/esm/detect.d.ts +3 -0
- package/dist/esm/detect.js +11 -0
- package/dist/esm/detect.js.map +7 -0
- package/dist/esm/features/haneulGetCapabilities.d.ts +15 -0
- package/dist/esm/features/haneulGetCapabilities.js +5 -0
- package/dist/esm/features/haneulGetCapabilities.js.map +7 -0
- package/dist/esm/features/haneulReportTransactionEffects.d.ts +26 -0
- package/dist/esm/features/haneulReportTransactionEffects.js +5 -0
- package/dist/esm/features/haneulReportTransactionEffects.js.map +7 -0
- package/dist/esm/features/haneulSignAndExecuteTransaction.d.ts +28 -0
- package/dist/esm/features/haneulSignAndExecuteTransaction.js +5 -0
- package/dist/esm/features/haneulSignAndExecuteTransaction.js.map +7 -0
- package/dist/esm/features/haneulSignAndExecuteTransactionBlock.d.ts +36 -0
- package/dist/esm/features/haneulSignAndExecuteTransactionBlock.js +5 -0
- package/dist/esm/features/haneulSignAndExecuteTransactionBlock.js.map +7 -0
- package/dist/esm/features/haneulSignMessage.d.ts +45 -0
- package/dist/esm/features/haneulSignMessage.js +5 -0
- package/dist/esm/features/haneulSignMessage.js.map +7 -0
- package/dist/esm/features/haneulSignPersonalMessage.d.ts +33 -0
- package/dist/esm/features/haneulSignPersonalMessage.js +5 -0
- package/dist/esm/features/haneulSignPersonalMessage.js.map +7 -0
- package/dist/esm/features/haneulSignTransaction.d.ts +34 -0
- package/dist/esm/features/haneulSignTransaction.js +5 -0
- package/dist/esm/features/haneulSignTransaction.js.map +7 -0
- package/dist/esm/features/haneulSignTransactionBlock.d.ts +38 -0
- package/dist/esm/features/haneulSignTransactionBlock.js +5 -0
- package/dist/esm/features/haneulSignTransactionBlock.js.map +7 -0
- package/dist/esm/features/index.d.ts +28 -0
- package/dist/esm/features/index.js +9 -0
- package/dist/esm/features/index.js.map +7 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +5 -0
- package/dist/esm/types.d.ts +159 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/types.js.map +7 -0
- package/dist/esm/wallet.d.ts +18 -0
- package/dist/esm/wallet.js +60 -0
- package/dist/esm/wallet.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +50 -0
- package/src/chains.ts +33 -0
- package/src/detect.ts +20 -0
- package/src/features/haneulGetCapabilities.ts +21 -0
- package/src/features/haneulReportTransactionEffects.ts +36 -0
- package/src/features/haneulSignAndExecuteTransaction.ts +38 -0
- package/src/features/haneulSignAndExecuteTransactionBlock.ts +51 -0
- package/src/features/haneulSignMessage.ts +54 -0
- package/src/features/haneulSignPersonalMessage.ts +44 -0
- package/src/features/haneulSignTransaction.ts +44 -0
- package/src/features/haneulSignTransactionBlock.ts +49 -0
- package/src/features/index.ts +61 -0
- package/src/index.ts +10 -0
- package/src/types.ts +175 -0
- package/src/wallet.ts +100 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { WalletAccount } from '@wallet-standard/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Name of the feature.
|
|
8
|
+
* @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
|
|
9
|
+
**/
|
|
10
|
+
export const HaneulSignMessage = 'sui:signMessage';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The latest API version of the signMessage API.
|
|
14
|
+
* @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
|
|
15
|
+
*/
|
|
16
|
+
export type HaneulSignMessageVersion = '1.0.0';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A Wallet Standard feature for signing a personal message, and returning the
|
|
20
|
+
* message bytes that were signed, and message signature.
|
|
21
|
+
*
|
|
22
|
+
* @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
|
|
23
|
+
*/
|
|
24
|
+
export type HaneulSignMessageFeature = {
|
|
25
|
+
/** Namespace for the feature. */
|
|
26
|
+
[HaneulSignMessage]: {
|
|
27
|
+
/** Version of the feature API. */
|
|
28
|
+
version: HaneulSignMessageVersion;
|
|
29
|
+
signMessage: HaneulSignMessageMethod;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/** @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature */
|
|
34
|
+
export type HaneulSignMessageMethod = (input: HaneulSignMessageInput) => Promise<HaneulSignMessageOutput>;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Input for signing messages.
|
|
38
|
+
* @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
|
|
39
|
+
*/
|
|
40
|
+
export interface HaneulSignMessageInput {
|
|
41
|
+
message: Uint8Array;
|
|
42
|
+
account: WalletAccount;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Output of signing messages.
|
|
47
|
+
* @deprecated Wallets can still implement this method for compatibility, but this has been replaced by the `sui:signPersonalMessage` feature
|
|
48
|
+
*/
|
|
49
|
+
export interface HaneulSignMessageOutput {
|
|
50
|
+
/** Base64 message bytes. */
|
|
51
|
+
messageBytes: string;
|
|
52
|
+
/** Base64 encoded signature */
|
|
53
|
+
signature: string;
|
|
54
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { IdentifierString, WalletAccount } from '@wallet-standard/core';
|
|
5
|
+
|
|
6
|
+
/** Name of the feature. */
|
|
7
|
+
export const HaneulSignPersonalMessage = 'sui:signPersonalMessage';
|
|
8
|
+
|
|
9
|
+
/** The latest API version of the signPersonalMessage API. */
|
|
10
|
+
export type HaneulSignPersonalMessageVersion = '1.1.0';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A Wallet Standard feature for signing a personal message, and returning the
|
|
14
|
+
* message bytes that were signed, and message signature.
|
|
15
|
+
*/
|
|
16
|
+
export type HaneulSignPersonalMessageFeature = {
|
|
17
|
+
/** Namespace for the feature. */
|
|
18
|
+
[HaneulSignPersonalMessage]: {
|
|
19
|
+
/** Version of the feature API. */
|
|
20
|
+
version: HaneulSignPersonalMessageVersion;
|
|
21
|
+
signPersonalMessage: HaneulSignPersonalMessageMethod;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type HaneulSignPersonalMessageMethod = (
|
|
26
|
+
input: HaneulSignPersonalMessageInput,
|
|
27
|
+
) => Promise<HaneulSignPersonalMessageOutput>;
|
|
28
|
+
|
|
29
|
+
/** Input for signing personal messages. */
|
|
30
|
+
export interface HaneulSignPersonalMessageInput {
|
|
31
|
+
message: Uint8Array;
|
|
32
|
+
account: WalletAccount;
|
|
33
|
+
chain?: IdentifierString;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Output of signing personal messages. */
|
|
37
|
+
export interface HaneulSignPersonalMessageOutput extends SignedPersonalMessage {}
|
|
38
|
+
|
|
39
|
+
export interface SignedPersonalMessage {
|
|
40
|
+
/** Base64 encoded message bytes */
|
|
41
|
+
bytes: string;
|
|
42
|
+
/** Base64 encoded signature */
|
|
43
|
+
signature: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { IdentifierString, WalletAccount } from '@wallet-standard/core';
|
|
5
|
+
|
|
6
|
+
/** Name of the feature. */
|
|
7
|
+
export const HaneulSignTransaction = 'sui:signTransaction';
|
|
8
|
+
|
|
9
|
+
/** The latest API version of the signTransaction API. */
|
|
10
|
+
export type HaneulSignTransactionVersion = '2.0.0';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A Wallet Standard feature for signing a transaction, and returning the
|
|
14
|
+
* serialized transaction and transaction signature.
|
|
15
|
+
*/
|
|
16
|
+
export type HaneulSignTransactionFeature = {
|
|
17
|
+
/** Namespace for the feature. */
|
|
18
|
+
[HaneulSignTransaction]: {
|
|
19
|
+
/** Version of the feature API. */
|
|
20
|
+
version: HaneulSignTransactionVersion;
|
|
21
|
+
signTransaction: HaneulSignTransactionMethod;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type HaneulSignTransactionMethod = (
|
|
26
|
+
input: HaneulSignTransactionInput,
|
|
27
|
+
) => Promise<SignedTransaction>;
|
|
28
|
+
|
|
29
|
+
/** Input for signing transactions. */
|
|
30
|
+
export interface HaneulSignTransactionInput {
|
|
31
|
+
transaction: { toJSON: () => Promise<string> };
|
|
32
|
+
account: WalletAccount;
|
|
33
|
+
chain: IdentifierString;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Output of signing transactions. */
|
|
38
|
+
|
|
39
|
+
export interface SignedTransaction {
|
|
40
|
+
/** Transaction as base64 encoded bcs. */
|
|
41
|
+
bytes: string;
|
|
42
|
+
/** Base64 encoded signature */
|
|
43
|
+
signature: string;
|
|
44
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { Transaction } from '@haneullabs/haneul/transactions';
|
|
5
|
+
import type { IdentifierString, WalletAccount } from '@wallet-standard/core';
|
|
6
|
+
|
|
7
|
+
/** Name of the feature. */
|
|
8
|
+
export const HaneulSignTransactionBlock = 'sui:signTransactionBlock';
|
|
9
|
+
|
|
10
|
+
/** The latest API version of the signTransactionBlock API. */
|
|
11
|
+
export type HaneulSignTransactionBlockVersion = '1.0.0';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `sui:signTransaction` instead.
|
|
15
|
+
*
|
|
16
|
+
* A Wallet Standard feature for signing a transaction, and returning the
|
|
17
|
+
* serialized transaction and transaction signature.
|
|
18
|
+
*/
|
|
19
|
+
export type HaneulSignTransactionBlockFeature = {
|
|
20
|
+
/** Namespace for the feature. */
|
|
21
|
+
[HaneulSignTransactionBlock]: {
|
|
22
|
+
/** Version of the feature API. */
|
|
23
|
+
version: HaneulSignTransactionBlockVersion;
|
|
24
|
+
/** @deprecated Use `sui:signTransaction` instead. */
|
|
25
|
+
signTransactionBlock: HaneulSignTransactionBlockMethod;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** @deprecated Use `sui:signTransaction` instead. */
|
|
30
|
+
export type HaneulSignTransactionBlockMethod = (
|
|
31
|
+
input: HaneulSignTransactionBlockInput,
|
|
32
|
+
) => Promise<HaneulSignTransactionBlockOutput>;
|
|
33
|
+
|
|
34
|
+
/** Input for signing transactions. */
|
|
35
|
+
export interface HaneulSignTransactionBlockInput {
|
|
36
|
+
transactionBlock: Transaction;
|
|
37
|
+
account: WalletAccount;
|
|
38
|
+
chain: IdentifierString;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Output of signing transactions. */
|
|
42
|
+
export interface HaneulSignTransactionBlockOutput extends SignedTransactionBlock {}
|
|
43
|
+
|
|
44
|
+
export interface SignedTransactionBlock {
|
|
45
|
+
/** Transaction as base64 encoded bcs. */
|
|
46
|
+
transactionBlockBytes: string;
|
|
47
|
+
/** Base64 encoded signature */
|
|
48
|
+
signature: string;
|
|
49
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
IdentifierRecord,
|
|
6
|
+
StandardConnectFeature,
|
|
7
|
+
StandardDisconnectFeature,
|
|
8
|
+
StandardEventsFeature,
|
|
9
|
+
WalletWithFeatures,
|
|
10
|
+
} from '@wallet-standard/core';
|
|
11
|
+
|
|
12
|
+
import type { HaneulReportTransactionEffectsFeature } from './haneulReportTransactionEffects.js';
|
|
13
|
+
import type { HaneulSignAndExecuteTransactionFeature } from './haneulSignAndExecuteTransaction.js';
|
|
14
|
+
import type { HaneulSignAndExecuteTransactionBlockFeature } from './haneulSignAndExecuteTransactionBlock.js';
|
|
15
|
+
import type { HaneulSignMessageFeature } from './haneulSignMessage.js';
|
|
16
|
+
import type { HaneulSignPersonalMessageFeature } from './haneulSignPersonalMessage.js';
|
|
17
|
+
import type { HaneulSignTransactionFeature } from './haneulSignTransaction.js';
|
|
18
|
+
import type { HaneulSignTransactionBlockFeature } from './haneulSignTransactionBlock.js';
|
|
19
|
+
import type { HaneulGetCapabilitiesFeature } from './haneulGetCapabilities.js';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Wallet Standard features that are unique to Haneul, and that all Haneul wallets are expected to implement.
|
|
23
|
+
*/
|
|
24
|
+
export type HaneulFeatures = Partial<HaneulSignTransactionBlockFeature> &
|
|
25
|
+
Partial<HaneulSignAndExecuteTransactionBlockFeature> &
|
|
26
|
+
HaneulSignPersonalMessageFeature &
|
|
27
|
+
HaneulSignAndExecuteTransactionFeature &
|
|
28
|
+
HaneulSignTransactionFeature &
|
|
29
|
+
// This deprecated feature should be removed once wallets update to the new method:
|
|
30
|
+
Partial<HaneulSignMessageFeature> &
|
|
31
|
+
Partial<HaneulReportTransactionEffectsFeature> &
|
|
32
|
+
Partial<HaneulGetCapabilitiesFeature>;
|
|
33
|
+
|
|
34
|
+
export type HaneulWalletFeatures = StandardConnectFeature &
|
|
35
|
+
StandardEventsFeature &
|
|
36
|
+
HaneulFeatures &
|
|
37
|
+
// Disconnect is an optional feature:
|
|
38
|
+
Partial<StandardDisconnectFeature>;
|
|
39
|
+
|
|
40
|
+
export type WalletWithHaneulFeatures = WalletWithFeatures<HaneulWalletFeatures>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Represents a wallet with the absolute minimum feature set required to function in the Haneul ecosystem.
|
|
44
|
+
*/
|
|
45
|
+
export type WalletWithRequiredFeatures = WalletWithFeatures<
|
|
46
|
+
MinimallyRequiredFeatures &
|
|
47
|
+
Partial<HaneulFeatures> &
|
|
48
|
+
Partial<StandardDisconnectFeature> &
|
|
49
|
+
IdentifierRecord<unknown>
|
|
50
|
+
>;
|
|
51
|
+
|
|
52
|
+
export type MinimallyRequiredFeatures = StandardConnectFeature & StandardEventsFeature;
|
|
53
|
+
|
|
54
|
+
export * from './haneulSignMessage.js';
|
|
55
|
+
export * from './haneulSignTransactionBlock.js';
|
|
56
|
+
export * from './haneulSignTransaction.js';
|
|
57
|
+
export * from './haneulSignAndExecuteTransactionBlock.js';
|
|
58
|
+
export * from './haneulSignAndExecuteTransaction.js';
|
|
59
|
+
export * from './haneulSignPersonalMessage.js';
|
|
60
|
+
export * from './haneulReportTransactionEffects.js';
|
|
61
|
+
export * from './haneulGetCapabilities.js';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export * from '@wallet-standard/core';
|
|
5
|
+
|
|
6
|
+
export { type Wallet, signAndExecuteTransaction, signTransaction } from './wallet.js';
|
|
7
|
+
export * from './features/index.js';
|
|
8
|
+
export * from './detect.js';
|
|
9
|
+
export * from './chains.js';
|
|
10
|
+
export * from './types.js';
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/** Contains data related to the gas payment for a Transaction */
|
|
5
|
+
export interface GasData {
|
|
6
|
+
/** The budget set for this transaction */
|
|
7
|
+
budget: string | number | null;
|
|
8
|
+
/** The gas price used for this transaction */
|
|
9
|
+
price: string | number | null;
|
|
10
|
+
/** The owner of the gas coins used to fund the transactions, this is either the sender or the gas sponsor */
|
|
11
|
+
owner: string | null;
|
|
12
|
+
/** The list of SUI coins to fund the transaction */
|
|
13
|
+
payment: { objectId: string; version: string; digest: string }[] | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Represent the serialized state of a partially built Transaction
|
|
18
|
+
* This format is designed to support transactions that have not been fully build
|
|
19
|
+
* allowing most properties to be omitted or set to null. It also supports
|
|
20
|
+
* unresolved object references, unresolved pure values, and Transaction Intents.
|
|
21
|
+
*/
|
|
22
|
+
export interface SerializedTransactionDataV2 {
|
|
23
|
+
version: 2;
|
|
24
|
+
/** The sender of the transaction */
|
|
25
|
+
sender: string | null | undefined;
|
|
26
|
+
/** The expiration of the transaction */
|
|
27
|
+
expiration: { Epoch: number } | { None: true } | null | undefined;
|
|
28
|
+
/** The gas data */
|
|
29
|
+
gasData: GasData;
|
|
30
|
+
/** The inputs to the transaction */
|
|
31
|
+
inputs: CallArg[];
|
|
32
|
+
/** The commands to execute */
|
|
33
|
+
commands: Command[];
|
|
34
|
+
/** Extra metadata for implementation specific use-cases */
|
|
35
|
+
extensions?: { [key: string]: unknown };
|
|
36
|
+
/** The digest of the transaction, may be set when the transaction is fully resolved */
|
|
37
|
+
digest: string | null | undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Represents an input to a Transaction, either as a fully resolved Object or Pure input
|
|
42
|
+
* or as an unresolved partial reference which needs to be resolved before the transaction
|
|
43
|
+
* can be serialized to bcs and executed.
|
|
44
|
+
*/
|
|
45
|
+
export type CallArg =
|
|
46
|
+
| {
|
|
47
|
+
Object: ObjectArg;
|
|
48
|
+
}
|
|
49
|
+
| {
|
|
50
|
+
Pure: PureArg;
|
|
51
|
+
}
|
|
52
|
+
| {
|
|
53
|
+
UnresolvedPure: UnresolvedPureArg;
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
UnresolvedObject: UnresolvedObjectArg;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export type ObjectArg =
|
|
60
|
+
| {
|
|
61
|
+
ImmOrOwnedObject: {
|
|
62
|
+
objectId: string;
|
|
63
|
+
version: string | number;
|
|
64
|
+
digest: string;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
SharedObject: {
|
|
69
|
+
objectId: string;
|
|
70
|
+
initialSharedVersion: string;
|
|
71
|
+
mutable: boolean;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
| {
|
|
75
|
+
Receiving: {
|
|
76
|
+
objectId: string;
|
|
77
|
+
version: string | number;
|
|
78
|
+
digest: string;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export interface PureArg {
|
|
83
|
+
bytes: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Represents an un-serialized pure value.
|
|
88
|
+
* The correct bcs schema will need to be determined before this value can be serialized to bcs */
|
|
89
|
+
export interface UnresolvedPureArg {
|
|
90
|
+
value: unknown;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Represents an unresolved object reference. This allows objects to be referenced by only their ID.
|
|
95
|
+
* version and digest details may also be added to unresolved object references.
|
|
96
|
+
* To fully resolve a reference, the correct ObjectArg type needs to be determined based on the type of object,
|
|
97
|
+
* and how it used in the transaction (eg, is it used mutably if it's shared, and is it a receiving object if it's not shared)
|
|
98
|
+
*/
|
|
99
|
+
export interface UnresolvedObjectArg {
|
|
100
|
+
objectId: string;
|
|
101
|
+
version?: string | null | undefined;
|
|
102
|
+
digest?: string | null | undefined;
|
|
103
|
+
initialSharedVersion?: string | null | undefined;
|
|
104
|
+
mutable?: boolean | null | undefined;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export type Argument =
|
|
108
|
+
| {
|
|
109
|
+
GasCoin: true;
|
|
110
|
+
}
|
|
111
|
+
| {
|
|
112
|
+
Input: number;
|
|
113
|
+
}
|
|
114
|
+
| {
|
|
115
|
+
Result: number;
|
|
116
|
+
}
|
|
117
|
+
| {
|
|
118
|
+
NestedResult: [number, number];
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export type Command =
|
|
122
|
+
| {
|
|
123
|
+
MoveCall: {
|
|
124
|
+
package: string;
|
|
125
|
+
module: string;
|
|
126
|
+
function: string;
|
|
127
|
+
typeArguments: string[];
|
|
128
|
+
arguments: Argument[];
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
| {
|
|
132
|
+
TransferObjects: {
|
|
133
|
+
objects: Argument[];
|
|
134
|
+
address: Argument;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
| {
|
|
138
|
+
SplitCoins: {
|
|
139
|
+
coin: Argument;
|
|
140
|
+
amounts: Argument[];
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
| {
|
|
144
|
+
MergeCoins: {
|
|
145
|
+
destination: Argument;
|
|
146
|
+
sources: Argument[];
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
| {
|
|
150
|
+
Publish: {
|
|
151
|
+
modules: string[];
|
|
152
|
+
dependencies: string[];
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
| {
|
|
156
|
+
MakeMoveVec: {
|
|
157
|
+
type: string | null;
|
|
158
|
+
elements: Argument[];
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
| {
|
|
162
|
+
Upgrade: {
|
|
163
|
+
modules: string[];
|
|
164
|
+
dependencies: string[];
|
|
165
|
+
package: string;
|
|
166
|
+
ticket: Argument;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
| {
|
|
170
|
+
$Intent: {
|
|
171
|
+
name: string;
|
|
172
|
+
inputs: { [key: string]: Argument | Argument[] };
|
|
173
|
+
data: { [key: string]: unknown };
|
|
174
|
+
};
|
|
175
|
+
};
|
package/src/wallet.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { bcs } from '@haneullabs/haneul/bcs';
|
|
5
|
+
import { Transaction } from '@haneullabs/haneul/transactions';
|
|
6
|
+
import { fromBase64, toBase64 } from '@haneullabs/haneul/utils';
|
|
7
|
+
import type { WalletWithFeatures } from '@wallet-standard/core';
|
|
8
|
+
|
|
9
|
+
import type {
|
|
10
|
+
HaneulSignAndExecuteTransactionInput,
|
|
11
|
+
HaneulSignTransactionInput,
|
|
12
|
+
HaneulWalletFeatures,
|
|
13
|
+
} from './features/index.js';
|
|
14
|
+
|
|
15
|
+
declare module '@wallet-standard/core' {
|
|
16
|
+
export interface Wallet {
|
|
17
|
+
/**
|
|
18
|
+
* Unique identifier of the Wallet.
|
|
19
|
+
*
|
|
20
|
+
* If not provided, the wallet name will be used as the identifier.
|
|
21
|
+
*/
|
|
22
|
+
readonly id?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface StandardConnectOutput {
|
|
26
|
+
supportedIntents?: string[];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type { Wallet } from '@wallet-standard/core';
|
|
31
|
+
|
|
32
|
+
export async function signAndExecuteTransaction(
|
|
33
|
+
wallet: WalletWithFeatures<Partial<HaneulWalletFeatures>>,
|
|
34
|
+
input: HaneulSignAndExecuteTransactionInput,
|
|
35
|
+
) {
|
|
36
|
+
if (wallet.features['sui:signAndExecuteTransaction']) {
|
|
37
|
+
return wallet.features['sui:signAndExecuteTransaction'].signAndExecuteTransaction(input);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (!wallet.features['sui:signAndExecuteTransactionBlock']) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
`Provided wallet (${wallet.name}) does not support the signAndExecuteTransaction feature.`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { signAndExecuteTransactionBlock } = wallet.features['sui:signAndExecuteTransactionBlock'];
|
|
47
|
+
|
|
48
|
+
const transactionBlock = Transaction.from(await input.transaction.toJSON());
|
|
49
|
+
const { digest, rawEffects, rawTransaction } = await signAndExecuteTransactionBlock({
|
|
50
|
+
account: input.account,
|
|
51
|
+
chain: input.chain,
|
|
52
|
+
transactionBlock,
|
|
53
|
+
options: {
|
|
54
|
+
showRawEffects: true,
|
|
55
|
+
showRawInput: true,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const [
|
|
60
|
+
{
|
|
61
|
+
txSignatures: [signature],
|
|
62
|
+
intentMessage: { value: bcsTransaction },
|
|
63
|
+
},
|
|
64
|
+
] = bcs.SenderSignedData.parse(fromBase64(rawTransaction!));
|
|
65
|
+
|
|
66
|
+
const bytes = bcs.TransactionData.serialize(bcsTransaction).toBase64();
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
digest,
|
|
70
|
+
signature,
|
|
71
|
+
bytes,
|
|
72
|
+
effects: toBase64(new Uint8Array(rawEffects!)),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function signTransaction(
|
|
77
|
+
wallet: WalletWithFeatures<Partial<HaneulWalletFeatures>>,
|
|
78
|
+
input: HaneulSignTransactionInput,
|
|
79
|
+
) {
|
|
80
|
+
if (wallet.features['sui:signTransaction']) {
|
|
81
|
+
return wallet.features['sui:signTransaction'].signTransaction(input);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (!wallet.features['sui:signTransactionBlock']) {
|
|
85
|
+
throw new Error(
|
|
86
|
+
`Provided wallet (${wallet.name}) does not support the signTransaction feature.`,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const { signTransactionBlock } = wallet.features['sui:signTransactionBlock'];
|
|
91
|
+
|
|
92
|
+
const transaction = Transaction.from(await input.transaction.toJSON());
|
|
93
|
+
const { transactionBlockBytes, signature } = await signTransactionBlock({
|
|
94
|
+
transactionBlock: transaction,
|
|
95
|
+
account: input.account,
|
|
96
|
+
chain: input.chain,
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return { bytes: transactionBlockBytes, signature };
|
|
100
|
+
}
|