@dynamic-labs/embedded-wallet-solana 3.0.0-alpha.12 → 3.0.0-alpha.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/CHANGELOG.md +46 -0
- package/package.json +9 -9
- package/src/lib/TurnkeySolanaWalletConnector/TurnkeySolanaSigner.cjs +3 -6
- package/src/lib/TurnkeySolanaWalletConnector/TurnkeySolanaSigner.d.ts +6 -2
- package/src/lib/TurnkeySolanaWalletConnector/TurnkeySolanaSigner.js +3 -6
- package/src/lib/TurnkeySolanaWalletConnector/TurnkeySolanaWalletConnector.cjs +40 -17
- package/src/lib/TurnkeySolanaWalletConnector/TurnkeySolanaWalletConnector.d.ts +2 -1
- package/src/lib/TurnkeySolanaWalletConnector/TurnkeySolanaWalletConnector.js +40 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,50 @@
|
|
|
1
1
|
|
|
2
|
+
## [3.0.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.13...v3.0.0-alpha.14) (2024-07-09)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* remove setPrimaryWallet in favor of useSwitchWallet (#6212)
|
|
8
|
+
* move getBalance method to wallet so it can be fetched for any wallet not just the active one (#6200)
|
|
9
|
+
* make Wallet a class instead of just a type (#6094)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add @dynamic-labs/solana-extension ([#6140](https://github.com/dynamic-labs/DynamicAuth/issues/6140)) ([c0e2a06](https://github.com/dynamic-labs/DynamicAuth/commit/c0e2a067dd83163094b58a15696df8654da47c65))
|
|
14
|
+
* add solana support for multi-asset ([#6222](https://github.com/dynamic-labs/DynamicAuth/issues/6222)) ([9660d79](https://github.com/dynamic-labs/DynamicAuth/commit/9660d7962f1fb01011d68397bb367fdfc5335ca9))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* allow closing re-connect wallet modal ([#6250](https://github.com/dynamic-labs/DynamicAuth/issues/6250)) ([55ba25b](https://github.com/dynamic-labs/DynamicAuth/commit/55ba25bd3e907629aaa26e788885bfa38f8fe350))
|
|
20
|
+
* move getBalance method to wallet so it can be fetched for any wallet not just the active one ([#6200](https://github.com/dynamic-labs/DynamicAuth/issues/6200)) ([ee94773](https://github.com/dynamic-labs/DynamicAuth/commit/ee94773df9b31462a325666760fcf1fc70dec68a))
|
|
21
|
+
* move getNameService method to wallet so name service data can be fetched for any wallet ([#6205](https://github.com/dynamic-labs/DynamicAuth/issues/6205)) ([6671ae9](https://github.com/dynamic-labs/DynamicAuth/commit/6671ae92532ffc1889e24519e75f47d336ac0da6))
|
|
22
|
+
* relax phone number length validation ([#6226](https://github.com/dynamic-labs/DynamicAuth/issues/6226)) ([f0969b4](https://github.com/dynamic-labs/DynamicAuth/commit/f0969b4fbdafde07125cddecb16b4bfd011ea65e))
|
|
23
|
+
* sdkHasLoaded flipping back to false with otp ([#6242](https://github.com/dynamic-labs/DynamicAuth/issues/6242)) ([32ad9dd](https://github.com/dynamic-labs/DynamicAuth/commit/32ad9dd2dae7775f494506773fb343fe1a249c65))
|
|
24
|
+
* send transaction demo undefined address/value ([#6248](https://github.com/dynamic-labs/DynamicAuth/issues/6248)) ([036a511](https://github.com/dynamic-labs/DynamicAuth/commit/036a511fb848ef461edd9b7a5d79d478b0f1cf23))
|
|
25
|
+
* set last active account on accountChange request ([#6218](https://github.com/dynamic-labs/DynamicAuth/issues/6218)) ([05797d2](https://github.com/dynamic-labs/DynamicAuth/commit/05797d292aab8b4de02555594d4d1bbd4c9543eb))
|
|
26
|
+
* show ledger toggle when linking wallet ([#6202](https://github.com/dynamic-labs/DynamicAuth/issues/6202)) ([a449c0b](https://github.com/dynamic-labs/DynamicAuth/commit/a449c0bfc4e3a75ccd7084b930c48fbd6c14f691))
|
|
27
|
+
* show user wallet in profile view on single wallet mode even if it's not primary ([#6187](https://github.com/dynamic-labs/DynamicAuth/issues/6187)) ([ffaaeb2](https://github.com/dynamic-labs/DynamicAuth/commit/ffaaeb2c6cbb2868a381d85451ae5574024156bb))
|
|
28
|
+
* stop auto-switching to connected secondary wallet if primary wallet is not connected ([#6196](https://github.com/dynamic-labs/DynamicAuth/issues/6196)) ([4e8bcd2](https://github.com/dynamic-labs/DynamicAuth/commit/4e8bcd2d02d3fca54a0ed29c45b386ae99266b84))
|
|
29
|
+
* stop coinbase and solflare popups when secondary ([#6225](https://github.com/dynamic-labs/DynamicAuth/issues/6225)) ([7e9c104](https://github.com/dynamic-labs/DynamicAuth/commit/7e9c1049a09c9fd513c9a2a746d6baac916f1bf4))
|
|
30
|
+
* stop sending double sign request on network switch ([e325709](https://github.com/dynamic-labs/DynamicAuth/commit/e325709bb5d2d1331fe16cc705398fc7b1cc292a))
|
|
31
|
+
* tunrkey solana signer accept uint8array message ([#6137](https://github.com/dynamic-labs/DynamicAuth/issues/6137)) ([70f89ce](https://github.com/dynamic-labs/DynamicAuth/commit/70f89ce0dafa4c99b318c9c5adce59083cd6d284))
|
|
32
|
+
* update formatting of phantom bitcoin publickey ([#6210](https://github.com/dynamic-labs/DynamicAuth/issues/6210)) ([f58cea9](https://github.com/dynamic-labs/DynamicAuth/commit/f58cea99333fd7c6af8f56f637ee32f1f7ce8d76))
|
|
33
|
+
* use white color in farcaster qr code when in dark mode ([#6245](https://github.com/dynamic-labs/DynamicAuth/issues/6245)) ([a91958d](https://github.com/dynamic-labs/DynamicAuth/commit/a91958d8773be138da8f54791c4c67866257bbad))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
* make Wallet a class instead of just a type ([#6094](https://github.com/dynamic-labs/DynamicAuth/issues/6094)) ([6dc4672](https://github.com/dynamic-labs/DynamicAuth/commit/6dc4672951cfadc22a6c569e74eae3485bd472f3))
|
|
37
|
+
* remove setPrimaryWallet in favor of useSwitchWallet ([#6212](https://github.com/dynamic-labs/DynamicAuth/issues/6212)) ([de125e1](https://github.com/dynamic-labs/DynamicAuth/commit/de125e1ebbc20507e4ec07f337f5f5fd13aabcbe))
|
|
38
|
+
|
|
39
|
+
## [3.0.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.12...v3.0.0-alpha.13) (2024-06-27)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* coinbase smart wallet better handling in iframes ([#6184](https://github.com/dynamic-labs/DynamicAuth/issues/6184)) ([2c4befe](https://github.com/dynamic-labs/DynamicAuth/commit/2c4befedd09e6a432139cb3d08ea61004c3896d5))
|
|
45
|
+
* show connected network name when icon url is missing ([#6191](https://github.com/dynamic-labs/DynamicAuth/issues/6191)) ([dafd9e3](https://github.com/dynamic-labs/DynamicAuth/commit/dafd9e323f47ca3d61556e9a8c84ba3bfd27af8f))
|
|
46
|
+
* use correct account when creating wallet client ([#6179](https://github.com/dynamic-labs/DynamicAuth/issues/6179)) ([4e45a15](https://github.com/dynamic-labs/DynamicAuth/commit/4e45a15b2d7221ec80df919aa93468a75a94bed3))
|
|
47
|
+
|
|
2
48
|
## [3.0.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v3.0.0-alpha.11...v3.0.0-alpha.12) (2024-06-27)
|
|
3
49
|
|
|
4
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/embedded-wallet-solana",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.14",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
"@turnkey/iframe-stamper": "2.0.0",
|
|
34
34
|
"@turnkey/solana": "0.3.1",
|
|
35
35
|
"@turnkey/webauthn-stamper": "0.5.0",
|
|
36
|
-
"@dynamic-labs/embedded-wallet": "3.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/rpc-provider-solana": "3.0.0-alpha.
|
|
38
|
-
"@dynamic-labs/rpc-providers": "3.0.0-alpha.
|
|
39
|
-
"@dynamic-labs/solana-utils": "3.0.0-alpha.
|
|
40
|
-
"@dynamic-labs/types": "3.0.0-alpha.
|
|
41
|
-
"@dynamic-labs/utils": "3.0.0-alpha.
|
|
42
|
-
"@dynamic-labs/wallet-book": "3.0.0-alpha.
|
|
43
|
-
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.
|
|
36
|
+
"@dynamic-labs/embedded-wallet": "3.0.0-alpha.14",
|
|
37
|
+
"@dynamic-labs/rpc-provider-solana": "3.0.0-alpha.14",
|
|
38
|
+
"@dynamic-labs/rpc-providers": "3.0.0-alpha.14",
|
|
39
|
+
"@dynamic-labs/solana-utils": "3.0.0-alpha.14",
|
|
40
|
+
"@dynamic-labs/types": "3.0.0-alpha.14",
|
|
41
|
+
"@dynamic-labs/utils": "3.0.0-alpha.14",
|
|
42
|
+
"@dynamic-labs/wallet-book": "3.0.0-alpha.14",
|
|
43
|
+
"@dynamic-labs/wallet-connector-core": "3.0.0-alpha.14",
|
|
44
44
|
"viem": "2.9.25"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {}
|
|
@@ -16,13 +16,10 @@ class TurnkeySolanaSigner {
|
|
|
16
16
|
? new web3_js.PublicKey(this.turnkeyAddress)
|
|
17
17
|
: undefined;
|
|
18
18
|
}
|
|
19
|
-
signMessage(
|
|
19
|
+
signMessage(encodedMessage) {
|
|
20
20
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const signedMessage = yield this.walletConnector.
|
|
22
|
-
|
|
23
|
-
throw new Error('Failed to sign message');
|
|
24
|
-
}
|
|
25
|
-
return signedMessage;
|
|
21
|
+
const signedMessage = yield this.walletConnector.signUint8ArrayMessage(encodedMessage);
|
|
22
|
+
return { signature: signedMessage };
|
|
26
23
|
});
|
|
27
24
|
}
|
|
28
25
|
signTransaction(transaction) {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { PublicKey, SendOptions, Transaction, TransactionSignature, VersionedTransaction } from '@solana/web3.js';
|
|
2
2
|
import { TurnkeySolanaWalletConnector } from './TurnkeySolanaWalletConnector';
|
|
3
|
+
type SignedMessage = {
|
|
4
|
+
signature: Uint8Array;
|
|
5
|
+
};
|
|
3
6
|
export type IEmbeddedWalletSolanaSigner = {
|
|
4
7
|
publicKey?: {
|
|
5
8
|
toBytes(): Uint8Array;
|
|
@@ -11,7 +14,7 @@ export type IEmbeddedWalletSolanaSigner = {
|
|
|
11
14
|
signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
|
|
12
15
|
signature: TransactionSignature;
|
|
13
16
|
}>;
|
|
14
|
-
signMessage(message:
|
|
17
|
+
signMessage(message: Uint8Array, encoding?: string): Promise<SignedMessage>;
|
|
15
18
|
connect: (args?: {
|
|
16
19
|
onlyIfTrusted: boolean;
|
|
17
20
|
}) => Promise<{
|
|
@@ -29,7 +32,7 @@ export declare class TurnkeySolanaSigner implements IEmbeddedWalletSolanaSigner
|
|
|
29
32
|
constructor({ walletConnector, }: {
|
|
30
33
|
walletConnector: TurnkeySolanaWalletConnector;
|
|
31
34
|
});
|
|
32
|
-
signMessage(
|
|
35
|
+
signMessage(encodedMessage: Uint8Array): Promise<SignedMessage>;
|
|
33
36
|
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
|
|
34
37
|
signAllTransactions<T extends Transaction | VersionedTransaction>(_transactions: T[]): Promise<T[]>;
|
|
35
38
|
signAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<{
|
|
@@ -43,3 +46,4 @@ export declare class TurnkeySolanaSigner implements IEmbeddedWalletSolanaSigner
|
|
|
43
46
|
} | undefined>;
|
|
44
47
|
disconnect(): Promise<void>;
|
|
45
48
|
}
|
|
49
|
+
export {};
|
|
@@ -12,13 +12,10 @@ class TurnkeySolanaSigner {
|
|
|
12
12
|
? new PublicKey(this.turnkeyAddress)
|
|
13
13
|
: undefined;
|
|
14
14
|
}
|
|
15
|
-
signMessage(
|
|
15
|
+
signMessage(encodedMessage) {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const signedMessage = yield this.walletConnector.
|
|
18
|
-
|
|
19
|
-
throw new Error('Failed to sign message');
|
|
20
|
-
}
|
|
21
|
-
return signedMessage;
|
|
17
|
+
const signedMessage = yield this.walletConnector.signUint8ArrayMessage(encodedMessage);
|
|
18
|
+
return { signature: signedMessage };
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
signTransaction(transaction) {
|
|
@@ -167,18 +167,11 @@ class TurnkeySolanaWalletConnector extends embeddedWallet.TurnkeyWalletConnector
|
|
|
167
167
|
}
|
|
168
168
|
getSigner() {
|
|
169
169
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
170
|
-
if (this.isSessionKeyCompatible()) {
|
|
171
|
-
yield this.createOrRestoreSession();
|
|
172
|
-
}
|
|
173
170
|
return new TurnkeySolanaSigner.TurnkeySolanaSigner({ walletConnector: this });
|
|
174
171
|
});
|
|
175
172
|
}
|
|
176
|
-
getBalance() {
|
|
173
|
+
getBalance(address) {
|
|
177
174
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
178
|
-
const address = this.getAccount();
|
|
179
|
-
if (!address) {
|
|
180
|
-
return undefined;
|
|
181
|
-
}
|
|
182
175
|
const connectionClient = this.getConnection();
|
|
183
176
|
const publicKey = new web3_js.PublicKey(address);
|
|
184
177
|
const balance = yield connectionClient.getBalance(publicKey);
|
|
@@ -186,33 +179,63 @@ class TurnkeySolanaWalletConnector extends embeddedWallet.TurnkeyWalletConnector
|
|
|
186
179
|
return solBalance.toString();
|
|
187
180
|
});
|
|
188
181
|
}
|
|
189
|
-
|
|
182
|
+
signUint8ArrayMessage(encodedMessage) {
|
|
190
183
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
191
184
|
if (!this.turnkeyAddress) {
|
|
192
185
|
throw new utils.DynamicError('No turnkey account');
|
|
193
186
|
}
|
|
194
187
|
const address = this.turnkeyAddress;
|
|
195
|
-
|
|
188
|
+
let signedMessageRaw;
|
|
189
|
+
yield this.createOrRestoreSession();
|
|
190
|
+
yield this.walletUiUtils.signMessage({
|
|
196
191
|
handler: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
192
|
+
const account = yield this.getTurnkeyAccount();
|
|
193
|
+
try {
|
|
194
|
+
signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
|
|
195
|
+
}
|
|
196
|
+
catch (_a) {
|
|
197
|
+
yield this.removeSessionKeys();
|
|
198
|
+
yield this.createOrRestoreSession({
|
|
199
|
+
ignoreRestore: true,
|
|
200
|
+
});
|
|
201
|
+
signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
|
|
202
|
+
}
|
|
201
203
|
return utils.bufferToBase64(signedMessageRaw || Buffer.from([]));
|
|
202
204
|
}),
|
|
203
|
-
message:
|
|
205
|
+
message: new TextDecoder().decode(encodedMessage),
|
|
204
206
|
});
|
|
205
|
-
|
|
207
|
+
if (!signedMessageRaw) {
|
|
208
|
+
throw new Error('Failed to sign message');
|
|
209
|
+
}
|
|
210
|
+
return signedMessageRaw;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
signMessage(messageToSign) {
|
|
214
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const enc = new TextEncoder();
|
|
216
|
+
const encodedMessage = enc.encode(messageToSign);
|
|
217
|
+
const signedRawMessage = yield this.signUint8ArrayMessage(encodedMessage);
|
|
218
|
+
return utils.bufferToBase64(signedRawMessage);
|
|
206
219
|
});
|
|
207
220
|
}
|
|
208
221
|
signTransaction(transaction) {
|
|
209
222
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
yield this.createOrRestoreSession();
|
|
210
224
|
const account = yield this.getTurnkeyAccount();
|
|
211
225
|
const address = this.turnkeyAddress;
|
|
212
226
|
if (!account || !address) {
|
|
213
227
|
throw new Error('No turnkey account');
|
|
214
228
|
}
|
|
215
|
-
|
|
229
|
+
try {
|
|
230
|
+
yield account.addSignature(transaction, address);
|
|
231
|
+
}
|
|
232
|
+
catch (_a) {
|
|
233
|
+
yield this.removeSessionKeys();
|
|
234
|
+
yield this.createOrRestoreSession({
|
|
235
|
+
ignoreRestore: true,
|
|
236
|
+
});
|
|
237
|
+
yield account.addSignature(transaction, address);
|
|
238
|
+
}
|
|
216
239
|
return transaction;
|
|
217
240
|
});
|
|
218
241
|
}
|
|
@@ -40,7 +40,8 @@ export declare class TurnkeySolanaWalletConnector extends TurnkeyWalletConnector
|
|
|
40
40
|
private createTurnkeyAccount;
|
|
41
41
|
private getTurnkeyAccount;
|
|
42
42
|
getSigner(): Promise<TurnkeySolanaSigner | undefined>;
|
|
43
|
-
getBalance(): Promise<string | undefined>;
|
|
43
|
+
getBalance(address: string): Promise<string | undefined>;
|
|
44
|
+
signUint8ArrayMessage(encodedMessage: Uint8Array): Promise<Uint8Array>;
|
|
44
45
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
45
46
|
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
|
|
46
47
|
internalSignAndSendTransaction<T extends Transaction | VersionedTransaction>(transaction: T, options?: SendOptions): Promise<string>;
|
|
@@ -163,18 +163,11 @@ class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase {
|
|
|
163
163
|
}
|
|
164
164
|
getSigner() {
|
|
165
165
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
if (this.isSessionKeyCompatible()) {
|
|
167
|
-
yield this.createOrRestoreSession();
|
|
168
|
-
}
|
|
169
166
|
return new TurnkeySolanaSigner({ walletConnector: this });
|
|
170
167
|
});
|
|
171
168
|
}
|
|
172
|
-
getBalance() {
|
|
169
|
+
getBalance(address) {
|
|
173
170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
-
const address = this.getAccount();
|
|
175
|
-
if (!address) {
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
171
|
const connectionClient = this.getConnection();
|
|
179
172
|
const publicKey = new PublicKey(address);
|
|
180
173
|
const balance = yield connectionClient.getBalance(publicKey);
|
|
@@ -182,33 +175,63 @@ class TurnkeySolanaWalletConnector extends TurnkeyWalletConnectorBase {
|
|
|
182
175
|
return solBalance.toString();
|
|
183
176
|
});
|
|
184
177
|
}
|
|
185
|
-
|
|
178
|
+
signUint8ArrayMessage(encodedMessage) {
|
|
186
179
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
180
|
if (!this.turnkeyAddress) {
|
|
188
181
|
throw new DynamicError('No turnkey account');
|
|
189
182
|
}
|
|
190
183
|
const address = this.turnkeyAddress;
|
|
191
|
-
|
|
184
|
+
let signedMessageRaw;
|
|
185
|
+
yield this.createOrRestoreSession();
|
|
186
|
+
yield this.walletUiUtils.signMessage({
|
|
192
187
|
handler: () => __awaiter(this, void 0, void 0, function* () {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
188
|
+
const account = yield this.getTurnkeyAccount();
|
|
189
|
+
try {
|
|
190
|
+
signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
|
|
191
|
+
}
|
|
192
|
+
catch (_a) {
|
|
193
|
+
yield this.removeSessionKeys();
|
|
194
|
+
yield this.createOrRestoreSession({
|
|
195
|
+
ignoreRestore: true,
|
|
196
|
+
});
|
|
197
|
+
signedMessageRaw = yield (account === null || account === void 0 ? void 0 : account.signMessage(encodedMessage, address));
|
|
198
|
+
}
|
|
197
199
|
return bufferToBase64(signedMessageRaw || Buffer.from([]));
|
|
198
200
|
}),
|
|
199
|
-
message:
|
|
201
|
+
message: new TextDecoder().decode(encodedMessage),
|
|
200
202
|
});
|
|
201
|
-
|
|
203
|
+
if (!signedMessageRaw) {
|
|
204
|
+
throw new Error('Failed to sign message');
|
|
205
|
+
}
|
|
206
|
+
return signedMessageRaw;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
signMessage(messageToSign) {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
211
|
+
const enc = new TextEncoder();
|
|
212
|
+
const encodedMessage = enc.encode(messageToSign);
|
|
213
|
+
const signedRawMessage = yield this.signUint8ArrayMessage(encodedMessage);
|
|
214
|
+
return bufferToBase64(signedRawMessage);
|
|
202
215
|
});
|
|
203
216
|
}
|
|
204
217
|
signTransaction(transaction) {
|
|
205
218
|
return __awaiter(this, void 0, void 0, function* () {
|
|
219
|
+
yield this.createOrRestoreSession();
|
|
206
220
|
const account = yield this.getTurnkeyAccount();
|
|
207
221
|
const address = this.turnkeyAddress;
|
|
208
222
|
if (!account || !address) {
|
|
209
223
|
throw new Error('No turnkey account');
|
|
210
224
|
}
|
|
211
|
-
|
|
225
|
+
try {
|
|
226
|
+
yield account.addSignature(transaction, address);
|
|
227
|
+
}
|
|
228
|
+
catch (_a) {
|
|
229
|
+
yield this.removeSessionKeys();
|
|
230
|
+
yield this.createOrRestoreSession({
|
|
231
|
+
ignoreRestore: true,
|
|
232
|
+
});
|
|
233
|
+
yield account.addSignature(transaction, address);
|
|
234
|
+
}
|
|
212
235
|
return transaction;
|
|
213
236
|
});
|
|
214
237
|
}
|