@dynamic-labs-wallet/sui 0.0.0-preview-124.2
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/index.cjs.d.ts +1 -0
- package/index.cjs.js +203 -0
- package/index.esm.d.ts +1 -0
- package/index.esm.js +201 -0
- package/package.json +33 -0
- package/src/client/client.d.ts +43 -0
- package/src/client/client.d.ts.map +1 -0
- package/src/client/constants.d.ts +7 -0
- package/src/client/constants.d.ts.map +1 -0
- package/src/client/index.d.ts +2 -0
- package/src/client/index.d.ts.map +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
package/index.cjs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.cjs.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var browser = require('@dynamic-labs-wallet/browser');
|
|
4
|
+
var ed25519 = require('@mysten/sui/keypairs/ed25519');
|
|
5
|
+
var cryptography = require('@mysten/sui/cryptography');
|
|
6
|
+
var verify = require('@mysten/sui/verify');
|
|
7
|
+
|
|
8
|
+
function _extends() {
|
|
9
|
+
_extends = Object.assign || function assign(target) {
|
|
10
|
+
for(var i = 1; i < arguments.length; i++){
|
|
11
|
+
var source = arguments[i];
|
|
12
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
13
|
+
}
|
|
14
|
+
return target;
|
|
15
|
+
};
|
|
16
|
+
return _extends.apply(this, arguments);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const ERROR_KEYGEN_FAILED = 'Error with keygen';
|
|
20
|
+
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating sui wallet account';
|
|
21
|
+
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
22
|
+
const ERROR_VERIFY_TRANSACTION_SIGNATURE = 'Error verifying transaction signature';
|
|
23
|
+
|
|
24
|
+
class DynamicSuiWalletClient extends browser.DynamicWalletClient {
|
|
25
|
+
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
26
|
+
try {
|
|
27
|
+
// Generate key shares for given threshold signature scheme (TSS)
|
|
28
|
+
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
29
|
+
chainName: this.chainName,
|
|
30
|
+
thresholdSignatureScheme,
|
|
31
|
+
onError,
|
|
32
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
33
|
+
// update wallet map
|
|
34
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
35
|
+
accountAddress: accountAddress,
|
|
36
|
+
walletId,
|
|
37
|
+
chainName: this.chainName,
|
|
38
|
+
thresholdSignatureScheme,
|
|
39
|
+
clientKeySharesBackupInfo: browser.getClientKeyShareBackupInfo()
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (!rawPublicKey || !clientKeyShares) {
|
|
44
|
+
throw new Error(ERROR_KEYGEN_FAILED);
|
|
45
|
+
}
|
|
46
|
+
const { accountAddress, publicKeyHex } = this.deriveAccountAddress({
|
|
47
|
+
rawPublicKey: rawPublicKey
|
|
48
|
+
});
|
|
49
|
+
// Update client key shares in wallet map
|
|
50
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
51
|
+
// TODO: remove this once iframe handling for secret shares is implemented
|
|
52
|
+
await this.setClientKeySharesToLocalStorage({
|
|
53
|
+
accountAddress,
|
|
54
|
+
clientKeyShares,
|
|
55
|
+
overwriteOrMerge: 'overwrite'
|
|
56
|
+
});
|
|
57
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
58
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
59
|
+
accountAddress,
|
|
60
|
+
clientKeyShares,
|
|
61
|
+
password
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
accountAddress,
|
|
65
|
+
rawPublicKey,
|
|
66
|
+
publicKeyHex,
|
|
67
|
+
clientKeyShares
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
71
|
+
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async getRawPublicKeyFromClientKeyShares({ chainName, clientKeyShare }) {
|
|
75
|
+
const chainConfig = browser.getMPCChainConfig(chainName);
|
|
76
|
+
const derivationPath = new Uint32Array(chainConfig.derivationPath);
|
|
77
|
+
const rawPublicKey = await this.derivePublicKey({
|
|
78
|
+
chainName,
|
|
79
|
+
keyShare: clientKeyShare,
|
|
80
|
+
derivationPath
|
|
81
|
+
});
|
|
82
|
+
return rawPublicKey;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Format Ed25519 signature to string that satisfies Sui signature standard
|
|
86
|
+
*/ async formatSignature(signatureEd25519, accountAddress) {
|
|
87
|
+
// get public key from keyshare
|
|
88
|
+
// TODO: handle this more gracefully from the client key shares if possible
|
|
89
|
+
const clientKeyShares = await this.getClientKeySharesFromLocalStorage({
|
|
90
|
+
accountAddress
|
|
91
|
+
});
|
|
92
|
+
const rawPublicKey = await this.getRawPublicKeyFromClientKeyShares({
|
|
93
|
+
chainName: this.chainName,
|
|
94
|
+
clientKeyShare: clientKeyShares[0]
|
|
95
|
+
});
|
|
96
|
+
const suiPublicKey = new ed25519.Ed25519PublicKey(rawPublicKey);
|
|
97
|
+
const serializedSignature = cryptography.toSerializedSignature({
|
|
98
|
+
signature: signatureEd25519,
|
|
99
|
+
signatureScheme: 'ED25519',
|
|
100
|
+
publicKey: suiPublicKey
|
|
101
|
+
});
|
|
102
|
+
return serializedSignature;
|
|
103
|
+
}
|
|
104
|
+
async verifyMessageSignature({ message, signature, accountAddress }) {
|
|
105
|
+
try {
|
|
106
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
107
|
+
const verifiedPublicKey = await verify.verifyPersonalMessageSignature(messageBytes, signature);
|
|
108
|
+
const isVerified = verifiedPublicKey.toSuiAddress().toLowerCase() === accountAddress.toLowerCase();
|
|
109
|
+
if (!isVerified) {
|
|
110
|
+
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
this.logger.error('Error verifying signature:', error);
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async verifyTransactionSignature({ message, signature, accountAddress }) {
|
|
118
|
+
try {
|
|
119
|
+
const txBytes = Uint8Array.from(Buffer.from(message, 'hex'));
|
|
120
|
+
const verifiedPublicKey = await verify.verifyTransactionSignature(txBytes, signature);
|
|
121
|
+
const isVerified = verifiedPublicKey.toSuiAddress().toLowerCase() === accountAddress.toLowerCase();
|
|
122
|
+
if (!isVerified) {
|
|
123
|
+
throw new Error(ERROR_VERIFY_TRANSACTION_SIGNATURE);
|
|
124
|
+
}
|
|
125
|
+
} catch (error) {
|
|
126
|
+
this.logger.error('Error verifying signature:', error);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async signMessage({ message, accountAddress, password = undefined }) {
|
|
131
|
+
if (!accountAddress) {
|
|
132
|
+
throw new Error('Account address is required');
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const signatureEd25519 = await this.sign({
|
|
136
|
+
message,
|
|
137
|
+
accountAddress: accountAddress,
|
|
138
|
+
chainName: this.chainName,
|
|
139
|
+
password,
|
|
140
|
+
intent: browser.MessageIntent.SIGN_MESSAGE
|
|
141
|
+
});
|
|
142
|
+
const formattedSignature = await this.formatSignature(signatureEd25519, accountAddress);
|
|
143
|
+
await this.verifyMessageSignature({
|
|
144
|
+
message,
|
|
145
|
+
signature: formattedSignature,
|
|
146
|
+
accountAddress
|
|
147
|
+
});
|
|
148
|
+
return formattedSignature;
|
|
149
|
+
} catch (error) {
|
|
150
|
+
this.logger.error('Error signing message:', error);
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async signTransaction({ message, accountAddress, password = undefined }) {
|
|
155
|
+
if (!accountAddress) {
|
|
156
|
+
throw new Error('Account address is required');
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
const signatureEd25519 = await this.sign({
|
|
160
|
+
message,
|
|
161
|
+
accountAddress: accountAddress,
|
|
162
|
+
chainName: this.chainName,
|
|
163
|
+
password,
|
|
164
|
+
intent: browser.MessageIntent.SIGN_TRANSACTION
|
|
165
|
+
});
|
|
166
|
+
const formattedSignature = await this.formatSignature(signatureEd25519, accountAddress);
|
|
167
|
+
await this.verifyTransactionSignature({
|
|
168
|
+
message,
|
|
169
|
+
signature: formattedSignature,
|
|
170
|
+
accountAddress
|
|
171
|
+
});
|
|
172
|
+
return formattedSignature;
|
|
173
|
+
} catch (error) {
|
|
174
|
+
this.logger.error('Error signing message:', error);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
deriveAccountAddress({ rawPublicKey }) {
|
|
179
|
+
const publicKey = new ed25519.Ed25519PublicKey(rawPublicKey);
|
|
180
|
+
const accountAddress = publicKey.toSuiAddress();
|
|
181
|
+
return {
|
|
182
|
+
accountAddress,
|
|
183
|
+
publicKeyHex: Buffer.from(rawPublicKey).toString('hex')
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
async getSuiWallets() {
|
|
187
|
+
const wallets = await this.getWallets();
|
|
188
|
+
const suiWallets = wallets.filter((wallet)=>wallet.chainName === 'sui');
|
|
189
|
+
return suiWallets;
|
|
190
|
+
}
|
|
191
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
|
|
192
|
+
super({
|
|
193
|
+
environmentId,
|
|
194
|
+
authToken,
|
|
195
|
+
baseApiUrl,
|
|
196
|
+
baseMPCRelayApiUrl,
|
|
197
|
+
storageKey,
|
|
198
|
+
debug
|
|
199
|
+
}), this.chainName = 'SUI';
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.DynamicSuiWalletClient = DynamicSuiWalletClient;
|
package/index.esm.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.esm.js
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { DynamicWalletClient, getClientKeyShareBackupInfo, getMPCChainConfig, MessageIntent } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
import { Ed25519PublicKey } from '@mysten/sui/keypairs/ed25519';
|
|
3
|
+
import { toSerializedSignature } from '@mysten/sui/cryptography';
|
|
4
|
+
import { verifyPersonalMessageSignature, verifyTransactionSignature } from '@mysten/sui/verify';
|
|
5
|
+
|
|
6
|
+
function _extends() {
|
|
7
|
+
_extends = Object.assign || function assign(target) {
|
|
8
|
+
for(var i = 1; i < arguments.length; i++){
|
|
9
|
+
var source = arguments[i];
|
|
10
|
+
for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
11
|
+
}
|
|
12
|
+
return target;
|
|
13
|
+
};
|
|
14
|
+
return _extends.apply(this, arguments);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const ERROR_KEYGEN_FAILED = 'Error with keygen';
|
|
18
|
+
const ERROR_CREATE_WALLET_ACCOUNT = 'Error creating sui wallet account';
|
|
19
|
+
const ERROR_VERIFY_MESSAGE_SIGNATURE = 'Error verifying message signature';
|
|
20
|
+
const ERROR_VERIFY_TRANSACTION_SIGNATURE = 'Error verifying transaction signature';
|
|
21
|
+
|
|
22
|
+
class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
23
|
+
async createWalletAccount({ thresholdSignatureScheme, password = undefined, onError }) {
|
|
24
|
+
try {
|
|
25
|
+
// Generate key shares for given threshold signature scheme (TSS)
|
|
26
|
+
const { rawPublicKey, clientKeyShares } = await this.keyGen({
|
|
27
|
+
chainName: this.chainName,
|
|
28
|
+
thresholdSignatureScheme,
|
|
29
|
+
onError,
|
|
30
|
+
onCeremonyComplete: (accountAddress, walletId)=>{
|
|
31
|
+
// update wallet map
|
|
32
|
+
this.walletMap[accountAddress] = _extends({}, this.walletMap[accountAddress] || {}, {
|
|
33
|
+
accountAddress: accountAddress,
|
|
34
|
+
walletId,
|
|
35
|
+
chainName: this.chainName,
|
|
36
|
+
thresholdSignatureScheme,
|
|
37
|
+
clientKeySharesBackupInfo: getClientKeyShareBackupInfo()
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (!rawPublicKey || !clientKeyShares) {
|
|
42
|
+
throw new Error(ERROR_KEYGEN_FAILED);
|
|
43
|
+
}
|
|
44
|
+
const { accountAddress, publicKeyHex } = this.deriveAccountAddress({
|
|
45
|
+
rawPublicKey: rawPublicKey
|
|
46
|
+
});
|
|
47
|
+
// Update client key shares in wallet map
|
|
48
|
+
// warning: this might result in race condition if `onCeremonyComplete` executes at the same time
|
|
49
|
+
// TODO: remove this once iframe handling for secret shares is implemented
|
|
50
|
+
await this.setClientKeySharesToLocalStorage({
|
|
51
|
+
accountAddress,
|
|
52
|
+
clientKeyShares,
|
|
53
|
+
overwriteOrMerge: 'overwrite'
|
|
54
|
+
});
|
|
55
|
+
// Backup the new wallet without waiting for the promise to resolve
|
|
56
|
+
void this.storeEncryptedBackupByWalletWithRetry({
|
|
57
|
+
accountAddress,
|
|
58
|
+
clientKeyShares,
|
|
59
|
+
password
|
|
60
|
+
});
|
|
61
|
+
return {
|
|
62
|
+
accountAddress,
|
|
63
|
+
rawPublicKey,
|
|
64
|
+
publicKeyHex,
|
|
65
|
+
clientKeyShares
|
|
66
|
+
};
|
|
67
|
+
} catch (error) {
|
|
68
|
+
this.logger.error(ERROR_CREATE_WALLET_ACCOUNT, error);
|
|
69
|
+
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async getRawPublicKeyFromClientKeyShares({ chainName, clientKeyShare }) {
|
|
73
|
+
const chainConfig = getMPCChainConfig(chainName);
|
|
74
|
+
const derivationPath = new Uint32Array(chainConfig.derivationPath);
|
|
75
|
+
const rawPublicKey = await this.derivePublicKey({
|
|
76
|
+
chainName,
|
|
77
|
+
keyShare: clientKeyShare,
|
|
78
|
+
derivationPath
|
|
79
|
+
});
|
|
80
|
+
return rawPublicKey;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Format Ed25519 signature to string that satisfies Sui signature standard
|
|
84
|
+
*/ async formatSignature(signatureEd25519, accountAddress) {
|
|
85
|
+
// get public key from keyshare
|
|
86
|
+
// TODO: handle this more gracefully from the client key shares if possible
|
|
87
|
+
const clientKeyShares = await this.getClientKeySharesFromLocalStorage({
|
|
88
|
+
accountAddress
|
|
89
|
+
});
|
|
90
|
+
const rawPublicKey = await this.getRawPublicKeyFromClientKeyShares({
|
|
91
|
+
chainName: this.chainName,
|
|
92
|
+
clientKeyShare: clientKeyShares[0]
|
|
93
|
+
});
|
|
94
|
+
const suiPublicKey = new Ed25519PublicKey(rawPublicKey);
|
|
95
|
+
const serializedSignature = toSerializedSignature({
|
|
96
|
+
signature: signatureEd25519,
|
|
97
|
+
signatureScheme: 'ED25519',
|
|
98
|
+
publicKey: suiPublicKey
|
|
99
|
+
});
|
|
100
|
+
return serializedSignature;
|
|
101
|
+
}
|
|
102
|
+
async verifyMessageSignature({ message, signature, accountAddress }) {
|
|
103
|
+
try {
|
|
104
|
+
const messageBytes = new TextEncoder().encode(message);
|
|
105
|
+
const verifiedPublicKey = await verifyPersonalMessageSignature(messageBytes, signature);
|
|
106
|
+
const isVerified = verifiedPublicKey.toSuiAddress().toLowerCase() === accountAddress.toLowerCase();
|
|
107
|
+
if (!isVerified) {
|
|
108
|
+
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
this.logger.error('Error verifying signature:', error);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
async verifyTransactionSignature({ message, signature, accountAddress }) {
|
|
116
|
+
try {
|
|
117
|
+
const txBytes = Uint8Array.from(Buffer.from(message, 'hex'));
|
|
118
|
+
const verifiedPublicKey = await verifyTransactionSignature(txBytes, signature);
|
|
119
|
+
const isVerified = verifiedPublicKey.toSuiAddress().toLowerCase() === accountAddress.toLowerCase();
|
|
120
|
+
if (!isVerified) {
|
|
121
|
+
throw new Error(ERROR_VERIFY_TRANSACTION_SIGNATURE);
|
|
122
|
+
}
|
|
123
|
+
} catch (error) {
|
|
124
|
+
this.logger.error('Error verifying signature:', error);
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async signMessage({ message, accountAddress, password = undefined }) {
|
|
129
|
+
if (!accountAddress) {
|
|
130
|
+
throw new Error('Account address is required');
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const signatureEd25519 = await this.sign({
|
|
134
|
+
message,
|
|
135
|
+
accountAddress: accountAddress,
|
|
136
|
+
chainName: this.chainName,
|
|
137
|
+
password,
|
|
138
|
+
intent: MessageIntent.SIGN_MESSAGE
|
|
139
|
+
});
|
|
140
|
+
const formattedSignature = await this.formatSignature(signatureEd25519, accountAddress);
|
|
141
|
+
await this.verifyMessageSignature({
|
|
142
|
+
message,
|
|
143
|
+
signature: formattedSignature,
|
|
144
|
+
accountAddress
|
|
145
|
+
});
|
|
146
|
+
return formattedSignature;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
this.logger.error('Error signing message:', error);
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async signTransaction({ message, accountAddress, password = undefined }) {
|
|
153
|
+
if (!accountAddress) {
|
|
154
|
+
throw new Error('Account address is required');
|
|
155
|
+
}
|
|
156
|
+
try {
|
|
157
|
+
const signatureEd25519 = await this.sign({
|
|
158
|
+
message,
|
|
159
|
+
accountAddress: accountAddress,
|
|
160
|
+
chainName: this.chainName,
|
|
161
|
+
password,
|
|
162
|
+
intent: MessageIntent.SIGN_TRANSACTION
|
|
163
|
+
});
|
|
164
|
+
const formattedSignature = await this.formatSignature(signatureEd25519, accountAddress);
|
|
165
|
+
await this.verifyTransactionSignature({
|
|
166
|
+
message,
|
|
167
|
+
signature: formattedSignature,
|
|
168
|
+
accountAddress
|
|
169
|
+
});
|
|
170
|
+
return formattedSignature;
|
|
171
|
+
} catch (error) {
|
|
172
|
+
this.logger.error('Error signing message:', error);
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
deriveAccountAddress({ rawPublicKey }) {
|
|
177
|
+
const publicKey = new Ed25519PublicKey(rawPublicKey);
|
|
178
|
+
const accountAddress = publicKey.toSuiAddress();
|
|
179
|
+
return {
|
|
180
|
+
accountAddress,
|
|
181
|
+
publicKeyHex: Buffer.from(rawPublicKey).toString('hex')
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
async getSuiWallets() {
|
|
185
|
+
const wallets = await this.getWallets();
|
|
186
|
+
const suiWallets = wallets.filter((wallet)=>wallet.chainName === 'sui');
|
|
187
|
+
return suiWallets;
|
|
188
|
+
}
|
|
189
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug }){
|
|
190
|
+
super({
|
|
191
|
+
environmentId,
|
|
192
|
+
authToken,
|
|
193
|
+
baseApiUrl,
|
|
194
|
+
baseMPCRelayApiUrl,
|
|
195
|
+
storageKey,
|
|
196
|
+
debug
|
|
197
|
+
}), this.chainName = 'SUI';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export { DynamicSuiWalletClient };
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dynamic-labs-wallet/sui",
|
|
3
|
+
"version": "0.0.0-preview-124.2",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@dynamic-labs-wallet/browser": "0.0.0-preview-124.2",
|
|
7
|
+
"@mysten/sui": "^1.26.0"
|
|
8
|
+
},
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"nx": {
|
|
13
|
+
"sourceRoot": "packages/sui/src",
|
|
14
|
+
"projectType": "library",
|
|
15
|
+
"name": "sui",
|
|
16
|
+
"targets": {
|
|
17
|
+
"build": {}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./index.cjs.js",
|
|
22
|
+
"module": "./index.esm.js",
|
|
23
|
+
"types": "./index.esm.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": "./package.json",
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./index.esm.d.ts",
|
|
28
|
+
"import": "./index.esm.js",
|
|
29
|
+
"require": "./index.cjs.js",
|
|
30
|
+
"default": "./index.cjs.js"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ClientKeyShare, DynamicWalletClient, EcdsaPublicKey, ThresholdSignatureScheme, DynamicWalletClientProps } from '@dynamic-labs-wallet/browser';
|
|
2
|
+
export declare class DynamicSuiWalletClient extends DynamicWalletClient {
|
|
3
|
+
readonly chainName = "SUI";
|
|
4
|
+
constructor({ environmentId, authToken, baseApiUrl, baseMPCRelayApiUrl, storageKey, debug, }: DynamicWalletClientProps);
|
|
5
|
+
createWalletAccount({ thresholdSignatureScheme, password, onError, }: {
|
|
6
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
7
|
+
password?: string;
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
}): Promise<{
|
|
10
|
+
accountAddress: string;
|
|
11
|
+
publicKeyHex: string;
|
|
12
|
+
rawPublicKey: EcdsaPublicKey | Uint8Array | undefined;
|
|
13
|
+
clientKeyShares: ClientKeyShare[];
|
|
14
|
+
}>;
|
|
15
|
+
getRawPublicKeyFromClientKeyShares({ chainName, clientKeyShare, }: {
|
|
16
|
+
chainName: string;
|
|
17
|
+
clientKeyShare: ClientKeyShare;
|
|
18
|
+
}): Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Format Ed25519 signature to string that satisfies Sui signature standard
|
|
21
|
+
*/
|
|
22
|
+
private formatSignature;
|
|
23
|
+
private verifyMessageSignature;
|
|
24
|
+
private verifyTransactionSignature;
|
|
25
|
+
signMessage({ message, accountAddress, password, }: {
|
|
26
|
+
message: string;
|
|
27
|
+
accountAddress: string;
|
|
28
|
+
password?: string;
|
|
29
|
+
}): Promise<string>;
|
|
30
|
+
signTransaction({ message, accountAddress, password, }: {
|
|
31
|
+
message: string;
|
|
32
|
+
accountAddress: string;
|
|
33
|
+
password?: string;
|
|
34
|
+
}): Promise<string>;
|
|
35
|
+
deriveAccountAddress({ rawPublicKey }: {
|
|
36
|
+
rawPublicKey: Uint8Array;
|
|
37
|
+
}): {
|
|
38
|
+
accountAddress: string;
|
|
39
|
+
publicKeyHex: string;
|
|
40
|
+
};
|
|
41
|
+
getSuiWallets(): Promise<any>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EAIzB,MAAM,8BAA8B,CAAC;AActC,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,UAAU,EACV,KAAK,GACN,EAAE,wBAAwB;IAWrB,mBAAmB,CAAC,EACxB,wBAAwB,EACxB,QAAoB,EACpB,OAAO,GACR,EAAE;QACD,wBAAwB,EAAE,wBAAwB,CAAC;QACnD,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC;QACV,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;QACtD,eAAe,EAAE,cAAc,EAAE,CAAC;KACnC,CAAC;IAwDI,kCAAkC,CAAC,EACvC,SAAS,EACT,cAAc,GACf,EAAE;QACD,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,cAAc,CAAC;KAChC;IAYD;;OAEG;YACW,eAAe;YAyBf,sBAAsB;YA6BtB,0BAA0B;IA6BlC,WAAW,CAAC,EAChB,OAAO,EACP,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCb,eAAe,CAAC,EACpB,OAAO,EACP,cAAc,EACd,QAAoB,GACrB,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,OAAO,CAAC,MAAM,CAAC;IA+BnB,oBAAoB,CAAC,EAAE,YAAY,EAAE,EAAE;QAAE,YAAY,EAAE,UAAU,CAAA;KAAE;;;;IAU7D,aAAa;CAOpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ERROR_KEYGEN_FAILED = "Error with keygen";
|
|
2
|
+
export declare const ERROR_CREATE_WALLET_ACCOUNT = "Error creating sui wallet account";
|
|
3
|
+
export declare const ERROR_SIGN_MESSAGE = "Error signing message";
|
|
4
|
+
export declare const ERROR_ACCOUNT_ADDRESS_REQUIRED = "Account address is required";
|
|
5
|
+
export declare const ERROR_VERIFY_MESSAGE_SIGNATURE = "Error verifying message signature";
|
|
6
|
+
export declare const ERROR_VERIFY_TRANSACTION_SIGNATURE = "Error verifying transaction signature";
|
|
7
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/client/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAEvD,eAAO,MAAM,2BAA2B,sCAAsC,CAAC;AAE/E,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAE1D,eAAO,MAAM,8BAA8B,gCAAgC,CAAC;AAE5E,eAAO,MAAM,8BAA8B,sCACN,CAAC;AAEtC,eAAO,MAAM,kCAAkC,0CACN,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
|