@solana-mobile/mobile-wallet-adapter-protocol-web3js 0.0.1-alpha.4 → 0.0.1-alpha.7
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/lib/cjs/index.browser.js +98 -84
- package/lib/cjs/index.js +98 -84
- package/lib/cjs/index.native.js +96 -91
- package/lib/esm/index.browser.mjs +98 -84
- package/lib/esm/index.mjs +98 -84
- package/lib/types/index.browser.d.mts +13 -10
- package/lib/types/index.browser.d.mts.map +1 -1
- package/lib/types/index.browser.d.ts +13 -10
- package/lib/types/index.browser.d.ts.map +1 -1
- package/lib/types/index.d.mts +13 -10
- package/lib/types/index.d.mts.map +1 -1
- package/lib/types/index.d.ts +13 -10
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.native.d.ts +13 -10
- package/lib/types/index.native.d.ts.map +1 -1
- package/package.json +4 -3
package/lib/cjs/index.browser.js
CHANGED
|
@@ -30,102 +30,116 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function
|
|
33
|
+
function fromUint8Array(byteArray) {
|
|
34
34
|
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function toUint8Array(base64EncodedByteArray) {
|
|
37
37
|
return new Uint8Array(window
|
|
38
38
|
.atob(base64EncodedByteArray)
|
|
39
39
|
.split('')
|
|
40
40
|
.map((c) => c.charCodeAt(0)));
|
|
41
41
|
}
|
|
42
|
+
|
|
42
43
|
function transact(callback, config) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const augmentedCallback = (
|
|
45
|
-
const augmentedAPI =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
45
|
+
const augmentedCallback = (wallet) => {
|
|
46
|
+
const augmentedAPI = new Proxy({}, {
|
|
47
|
+
get(target, p) {
|
|
48
|
+
if (target[p] == null) {
|
|
49
|
+
switch (p) {
|
|
50
|
+
case 'signAndSendTransaction':
|
|
51
|
+
target[p] = function (params) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
let latestBlockhashPromise;
|
|
54
|
+
function getLatestBlockhash(connection) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (latestBlockhashPromise == null) {
|
|
57
|
+
latestBlockhashPromise = connection.getLatestBlockhash({
|
|
58
|
+
commitment: connection.commitment,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return yield latestBlockhashPromise;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
if (transaction.feePayer == null) {
|
|
66
|
+
transaction.feePayer = params.fee_payer;
|
|
67
|
+
}
|
|
68
|
+
if (transaction.recentBlockhash == null) {
|
|
69
|
+
const { blockhash } = yield getLatestBlockhash(params.connection);
|
|
70
|
+
transaction.recentBlockhash = blockhash;
|
|
71
|
+
}
|
|
72
|
+
const serializedTransaction = transaction.serialize({
|
|
73
|
+
requireAllSignatures: false,
|
|
74
|
+
verifySignatures: false,
|
|
75
|
+
});
|
|
76
|
+
return serializedTransaction.toString('base64');
|
|
77
|
+
})));
|
|
78
|
+
let targetCommitment;
|
|
79
|
+
switch (params.connection.commitment) {
|
|
80
|
+
case 'confirmed':
|
|
81
|
+
case 'finalized':
|
|
82
|
+
case 'processed':
|
|
83
|
+
targetCommitment = params.connection.commitment;
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
targetCommitment = 'finalized';
|
|
87
|
+
}
|
|
88
|
+
const { signatures } = yield wallet.signAndSendTransaction({
|
|
89
|
+
auth_token: params.auth_token,
|
|
90
|
+
commitment: targetCommitment,
|
|
91
|
+
payloads,
|
|
92
|
+
});
|
|
93
|
+
return signatures;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
break;
|
|
97
|
+
case 'signMessage':
|
|
98
|
+
target[p] = function (params) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const payloads = params.payloads.map(fromUint8Array);
|
|
101
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
|
|
102
|
+
auth_token: params.auth_token,
|
|
103
|
+
payloads,
|
|
104
|
+
});
|
|
105
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
106
|
+
return signedMessages;
|
|
107
|
+
});
|
|
108
|
+
};
|
|
87
109
|
break;
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
case 'signTransaction':
|
|
111
|
+
target[p] = function (params) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
|
|
114
|
+
requireAllSignatures: false,
|
|
115
|
+
verifySignatures: false,
|
|
116
|
+
}));
|
|
117
|
+
const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
|
|
118
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
|
|
119
|
+
auth_token: params.auth_token,
|
|
120
|
+
payloads,
|
|
121
|
+
});
|
|
122
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
123
|
+
const transactions = compiledTransactions.map(web3_js.Transaction.from);
|
|
124
|
+
return transactions;
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
break;
|
|
128
|
+
default: {
|
|
129
|
+
target[p] = wallet[p];
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
90
132
|
}
|
|
91
|
-
const { signatures } = yield walletAPI({
|
|
92
|
-
method: 'sign_and_send_transaction',
|
|
93
|
-
auth_token: apiCall.auth_token,
|
|
94
|
-
commitment: targetCommitment,
|
|
95
|
-
payloads,
|
|
96
|
-
});
|
|
97
|
-
return signatures;
|
|
98
|
-
}
|
|
99
|
-
case 'sign_message': {
|
|
100
|
-
const payloads = apiCall.byteArrays.map(getBase64StringFromByteArray);
|
|
101
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield walletAPI({
|
|
102
|
-
method: 'sign_message',
|
|
103
|
-
auth_token: apiCall.auth_token,
|
|
104
|
-
payloads,
|
|
105
|
-
});
|
|
106
|
-
const signedMessages = base64EncodedSignedMessages.map(getByteArrayFromBase64String);
|
|
107
|
-
return signedMessages;
|
|
108
|
-
}
|
|
109
|
-
case 'sign_transaction': {
|
|
110
|
-
const serializedTransactions = apiCall.transactions.map((transaction) => transaction.serialize({
|
|
111
|
-
requireAllSignatures: false,
|
|
112
|
-
verifySignatures: false,
|
|
113
|
-
}));
|
|
114
|
-
const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
|
|
115
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield walletAPI({
|
|
116
|
-
method: 'sign_transaction',
|
|
117
|
-
auth_token: apiCall.auth_token,
|
|
118
|
-
payloads,
|
|
119
|
-
});
|
|
120
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
|
|
121
|
-
const transactions = compiledTransactions.map(web3_js.Transaction.from);
|
|
122
|
-
return transactions;
|
|
123
133
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
return target[p];
|
|
135
|
+
},
|
|
136
|
+
defineProperty() {
|
|
137
|
+
return false;
|
|
138
|
+
},
|
|
139
|
+
deleteProperty() {
|
|
140
|
+
return false;
|
|
141
|
+
},
|
|
142
|
+
});
|
|
129
143
|
return callback(augmentedAPI);
|
|
130
144
|
};
|
|
131
145
|
return yield mobileWalletAdapterProtocol.transact(augmentedCallback, config);
|
package/lib/cjs/index.js
CHANGED
|
@@ -30,102 +30,116 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function
|
|
33
|
+
function fromUint8Array(byteArray) {
|
|
34
34
|
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function toUint8Array(base64EncodedByteArray) {
|
|
37
37
|
return new Uint8Array(window
|
|
38
38
|
.atob(base64EncodedByteArray)
|
|
39
39
|
.split('')
|
|
40
40
|
.map((c) => c.charCodeAt(0)));
|
|
41
41
|
}
|
|
42
|
+
|
|
42
43
|
function transact(callback, config) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const augmentedCallback = (
|
|
45
|
-
const augmentedAPI =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
45
|
+
const augmentedCallback = (wallet) => {
|
|
46
|
+
const augmentedAPI = new Proxy({}, {
|
|
47
|
+
get(target, p) {
|
|
48
|
+
if (target[p] == null) {
|
|
49
|
+
switch (p) {
|
|
50
|
+
case 'signAndSendTransaction':
|
|
51
|
+
target[p] = function (params) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
let latestBlockhashPromise;
|
|
54
|
+
function getLatestBlockhash(connection) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (latestBlockhashPromise == null) {
|
|
57
|
+
latestBlockhashPromise = connection.getLatestBlockhash({
|
|
58
|
+
commitment: connection.commitment,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return yield latestBlockhashPromise;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
if (transaction.feePayer == null) {
|
|
66
|
+
transaction.feePayer = params.fee_payer;
|
|
67
|
+
}
|
|
68
|
+
if (transaction.recentBlockhash == null) {
|
|
69
|
+
const { blockhash } = yield getLatestBlockhash(params.connection);
|
|
70
|
+
transaction.recentBlockhash = blockhash;
|
|
71
|
+
}
|
|
72
|
+
const serializedTransaction = transaction.serialize({
|
|
73
|
+
requireAllSignatures: false,
|
|
74
|
+
verifySignatures: false,
|
|
75
|
+
});
|
|
76
|
+
return serializedTransaction.toString('base64');
|
|
77
|
+
})));
|
|
78
|
+
let targetCommitment;
|
|
79
|
+
switch (params.connection.commitment) {
|
|
80
|
+
case 'confirmed':
|
|
81
|
+
case 'finalized':
|
|
82
|
+
case 'processed':
|
|
83
|
+
targetCommitment = params.connection.commitment;
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
targetCommitment = 'finalized';
|
|
87
|
+
}
|
|
88
|
+
const { signatures } = yield wallet.signAndSendTransaction({
|
|
89
|
+
auth_token: params.auth_token,
|
|
90
|
+
commitment: targetCommitment,
|
|
91
|
+
payloads,
|
|
92
|
+
});
|
|
93
|
+
return signatures;
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
break;
|
|
97
|
+
case 'signMessage':
|
|
98
|
+
target[p] = function (params) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
const payloads = params.payloads.map(fromUint8Array);
|
|
101
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
|
|
102
|
+
auth_token: params.auth_token,
|
|
103
|
+
payloads,
|
|
104
|
+
});
|
|
105
|
+
const signedMessages = base64EncodedSignedMessages.map(toUint8Array);
|
|
106
|
+
return signedMessages;
|
|
107
|
+
});
|
|
108
|
+
};
|
|
87
109
|
break;
|
|
88
|
-
|
|
89
|
-
|
|
110
|
+
case 'signTransaction':
|
|
111
|
+
target[p] = function (params) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
|
|
114
|
+
requireAllSignatures: false,
|
|
115
|
+
verifySignatures: false,
|
|
116
|
+
}));
|
|
117
|
+
const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
|
|
118
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
|
|
119
|
+
auth_token: params.auth_token,
|
|
120
|
+
payloads,
|
|
121
|
+
});
|
|
122
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(toUint8Array);
|
|
123
|
+
const transactions = compiledTransactions.map(web3_js.Transaction.from);
|
|
124
|
+
return transactions;
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
break;
|
|
128
|
+
default: {
|
|
129
|
+
target[p] = wallet[p];
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
90
132
|
}
|
|
91
|
-
const { signatures } = yield walletAPI({
|
|
92
|
-
method: 'sign_and_send_transaction',
|
|
93
|
-
auth_token: apiCall.auth_token,
|
|
94
|
-
commitment: targetCommitment,
|
|
95
|
-
payloads,
|
|
96
|
-
});
|
|
97
|
-
return signatures;
|
|
98
|
-
}
|
|
99
|
-
case 'sign_message': {
|
|
100
|
-
const payloads = apiCall.byteArrays.map(getBase64StringFromByteArray);
|
|
101
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield walletAPI({
|
|
102
|
-
method: 'sign_message',
|
|
103
|
-
auth_token: apiCall.auth_token,
|
|
104
|
-
payloads,
|
|
105
|
-
});
|
|
106
|
-
const signedMessages = base64EncodedSignedMessages.map(getByteArrayFromBase64String);
|
|
107
|
-
return signedMessages;
|
|
108
|
-
}
|
|
109
|
-
case 'sign_transaction': {
|
|
110
|
-
const serializedTransactions = apiCall.transactions.map((transaction) => transaction.serialize({
|
|
111
|
-
requireAllSignatures: false,
|
|
112
|
-
verifySignatures: false,
|
|
113
|
-
}));
|
|
114
|
-
const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
|
|
115
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield walletAPI({
|
|
116
|
-
method: 'sign_transaction',
|
|
117
|
-
auth_token: apiCall.auth_token,
|
|
118
|
-
payloads,
|
|
119
|
-
});
|
|
120
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
|
|
121
|
-
const transactions = compiledTransactions.map(web3_js.Transaction.from);
|
|
122
|
-
return transactions;
|
|
123
133
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
return target[p];
|
|
135
|
+
},
|
|
136
|
+
defineProperty() {
|
|
137
|
+
return false;
|
|
138
|
+
},
|
|
139
|
+
deleteProperty() {
|
|
140
|
+
return false;
|
|
141
|
+
},
|
|
142
|
+
});
|
|
129
143
|
return callback(augmentedAPI);
|
|
130
144
|
};
|
|
131
145
|
return yield mobileWalletAdapterProtocol.transact(augmentedCallback, config);
|
package/lib/cjs/index.native.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var web3_js = require('@solana/web3.js');
|
|
6
6
|
var mobileWalletAdapterProtocol = require('@solana-mobile/mobile-wallet-adapter-protocol');
|
|
7
|
+
var jsBase64 = require('js-base64');
|
|
7
8
|
|
|
8
9
|
/******************************************************************************
|
|
9
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -30,102 +31,106 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
function getBase64StringFromByteArray(byteArray) {
|
|
34
|
-
return window.btoa(String.fromCharCode.call(null, ...byteArray));
|
|
35
|
-
}
|
|
36
|
-
function getByteArrayFromBase64String(base64EncodedByteArray) {
|
|
37
|
-
return new Uint8Array(window
|
|
38
|
-
.atob(base64EncodedByteArray)
|
|
39
|
-
.split('')
|
|
40
|
-
.map((c) => c.charCodeAt(0)));
|
|
41
|
-
}
|
|
42
34
|
function transact(callback, config) {
|
|
43
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const augmentedCallback = (
|
|
45
|
-
const augmentedAPI =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
36
|
+
const augmentedCallback = (wallet) => {
|
|
37
|
+
const augmentedAPI = new Proxy({}, {
|
|
38
|
+
get(target, p) {
|
|
39
|
+
if (target[p] == null) {
|
|
40
|
+
switch (p) {
|
|
41
|
+
case 'signAndSendTransaction':
|
|
42
|
+
target[p] = function (params) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
let latestBlockhashPromise;
|
|
45
|
+
function getLatestBlockhash(connection) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (latestBlockhashPromise == null) {
|
|
48
|
+
latestBlockhashPromise = connection.getLatestBlockhash({
|
|
49
|
+
commitment: connection.commitment,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return yield latestBlockhashPromise;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const payloads = yield Promise.all(params.transactions.map((transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (transaction.feePayer == null) {
|
|
57
|
+
transaction.feePayer = params.fee_payer;
|
|
58
|
+
}
|
|
59
|
+
if (transaction.recentBlockhash == null) {
|
|
60
|
+
const { blockhash } = yield getLatestBlockhash(params.connection);
|
|
61
|
+
transaction.recentBlockhash = blockhash;
|
|
62
|
+
}
|
|
63
|
+
const serializedTransaction = transaction.serialize({
|
|
64
|
+
requireAllSignatures: false,
|
|
65
|
+
verifySignatures: false,
|
|
66
|
+
});
|
|
67
|
+
return serializedTransaction.toString('base64');
|
|
68
|
+
})));
|
|
69
|
+
let targetCommitment;
|
|
70
|
+
switch (params.connection.commitment) {
|
|
71
|
+
case 'confirmed':
|
|
72
|
+
case 'finalized':
|
|
73
|
+
case 'processed':
|
|
74
|
+
targetCommitment = params.connection.commitment;
|
|
75
|
+
break;
|
|
76
|
+
default:
|
|
77
|
+
targetCommitment = 'finalized';
|
|
78
|
+
}
|
|
79
|
+
const { signatures } = yield wallet.signAndSendTransaction({
|
|
80
|
+
auth_token: params.auth_token,
|
|
81
|
+
commitment: targetCommitment,
|
|
82
|
+
payloads,
|
|
83
|
+
});
|
|
84
|
+
return signatures;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
break;
|
|
88
|
+
case 'signMessage':
|
|
89
|
+
target[p] = function (params) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const payloads = params.payloads.map(jsBase64.fromUint8Array);
|
|
92
|
+
const { signed_payloads: base64EncodedSignedMessages } = yield wallet.signMessage({
|
|
93
|
+
auth_token: params.auth_token,
|
|
94
|
+
payloads,
|
|
95
|
+
});
|
|
96
|
+
const signedMessages = base64EncodedSignedMessages.map(jsBase64.toUint8Array);
|
|
97
|
+
return signedMessages;
|
|
98
|
+
});
|
|
99
|
+
};
|
|
87
100
|
break;
|
|
88
|
-
|
|
89
|
-
|
|
101
|
+
case 'signTransaction':
|
|
102
|
+
target[p] = function (params) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const serializedTransactions = params.transactions.map((transaction) => transaction.serialize({
|
|
105
|
+
requireAllSignatures: false,
|
|
106
|
+
verifySignatures: false,
|
|
107
|
+
}));
|
|
108
|
+
const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
|
|
109
|
+
const { signed_payloads: base64EncodedCompiledTransactions } = yield wallet.signTransaction({
|
|
110
|
+
auth_token: params.auth_token,
|
|
111
|
+
payloads,
|
|
112
|
+
});
|
|
113
|
+
const compiledTransactions = base64EncodedCompiledTransactions.map(jsBase64.toUint8Array);
|
|
114
|
+
const transactions = compiledTransactions.map(web3_js.Transaction.from);
|
|
115
|
+
return transactions;
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
break;
|
|
119
|
+
default: {
|
|
120
|
+
target[p] = wallet[p];
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
90
123
|
}
|
|
91
|
-
const { signatures } = yield walletAPI({
|
|
92
|
-
method: 'sign_and_send_transaction',
|
|
93
|
-
auth_token: apiCall.auth_token,
|
|
94
|
-
commitment: targetCommitment,
|
|
95
|
-
payloads,
|
|
96
|
-
});
|
|
97
|
-
return signatures;
|
|
98
|
-
}
|
|
99
|
-
case 'sign_message': {
|
|
100
|
-
const payloads = apiCall.byteArrays.map(getBase64StringFromByteArray);
|
|
101
|
-
const { signed_payloads: base64EncodedSignedMessages } = yield walletAPI({
|
|
102
|
-
method: 'sign_message',
|
|
103
|
-
auth_token: apiCall.auth_token,
|
|
104
|
-
payloads,
|
|
105
|
-
});
|
|
106
|
-
const signedMessages = base64EncodedSignedMessages.map(getByteArrayFromBase64String);
|
|
107
|
-
return signedMessages;
|
|
108
|
-
}
|
|
109
|
-
case 'sign_transaction': {
|
|
110
|
-
const serializedTransactions = apiCall.transactions.map((transaction) => transaction.serialize({
|
|
111
|
-
requireAllSignatures: false,
|
|
112
|
-
verifySignatures: false,
|
|
113
|
-
}));
|
|
114
|
-
const payloads = serializedTransactions.map((serializedTransaction) => serializedTransaction.toString('base64'));
|
|
115
|
-
const { signed_payloads: base64EncodedCompiledTransactions } = yield walletAPI({
|
|
116
|
-
method: 'sign_transaction',
|
|
117
|
-
auth_token: apiCall.auth_token,
|
|
118
|
-
payloads,
|
|
119
|
-
});
|
|
120
|
-
const compiledTransactions = base64EncodedCompiledTransactions.map(getByteArrayFromBase64String);
|
|
121
|
-
const transactions = compiledTransactions.map(web3_js.Transaction.from);
|
|
122
|
-
return transactions;
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
return target[p];
|
|
126
|
+
},
|
|
127
|
+
defineProperty() {
|
|
128
|
+
return false;
|
|
129
|
+
},
|
|
130
|
+
deleteProperty() {
|
|
131
|
+
return false;
|
|
132
|
+
},
|
|
133
|
+
});
|
|
129
134
|
return callback(augmentedAPI);
|
|
130
135
|
};
|
|
131
136
|
return yield mobileWalletAdapterProtocol.transact(augmentedCallback, config);
|