@getpara/solana-web3.js-v1-integration 1.5.0 → 1.6.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/dist/cjs/index.js +56 -28
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/index.js +15687 -31
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/dist/esm/package.json +4 -0
- package/dist/types/solana-web3js.d.ts +1 -0
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
|
|
29
49
|
// src/index.ts
|
|
30
50
|
var src_exports = {};
|
|
@@ -45,37 +65,45 @@ var ParaSolanaWeb3Signer = class {
|
|
|
45
65
|
this.address = para.wallets[this.currentWalletId].address;
|
|
46
66
|
this.sender = this.address ? new solana.PublicKey(import_bs58.default.decode(this.address)) : void 0;
|
|
47
67
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
68
|
+
signBytes(bytes) {
|
|
69
|
+
return __async(this, null, function* () {
|
|
70
|
+
const res = yield this.para.signMessage({ walletId: this.currentWalletId, messageBase64: bytes.toString("base64") });
|
|
71
|
+
if (res.transactionReviewUrl) {
|
|
72
|
+
throw new import_core_sdk.TransactionReviewError(res.transactionReviewUrl);
|
|
73
|
+
}
|
|
74
|
+
return Buffer.from(res.signature, "base64");
|
|
75
|
+
});
|
|
54
76
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
transaction.recentBlockhash
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
signTransaction(transaction) {
|
|
78
|
+
return __async(this, null, function* () {
|
|
79
|
+
if (transaction instanceof solana.VersionedTransaction) {
|
|
80
|
+
return yield this.signVersionedTransaction(transaction);
|
|
81
|
+
}
|
|
82
|
+
if (!transaction.recentBlockhash) {
|
|
83
|
+
transaction.recentBlockhash = (yield this.connection.getLatestBlockhash("finalized")).blockhash;
|
|
84
|
+
}
|
|
85
|
+
const bytesToSign = transaction.serializeMessage();
|
|
86
|
+
const sigBytes = yield this.signBytes(bytesToSign);
|
|
87
|
+
transaction.addSignature(this.sender, sigBytes);
|
|
88
|
+
return transaction;
|
|
89
|
+
});
|
|
66
90
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
transaction.message.recentBlockhash
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
91
|
+
signVersionedTransaction(transaction) {
|
|
92
|
+
return __async(this, null, function* () {
|
|
93
|
+
if (!transaction.message.recentBlockhash) {
|
|
94
|
+
transaction.message.recentBlockhash = (yield this.connection.getLatestBlockhash("finalized")).blockhash;
|
|
95
|
+
}
|
|
96
|
+
const messageBytes = transaction.message.serialize();
|
|
97
|
+
const sigBytes = yield this.signBytes(Buffer.from(messageBytes));
|
|
98
|
+
transaction.addSignature(this.sender, sigBytes);
|
|
99
|
+
return transaction;
|
|
100
|
+
});
|
|
75
101
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
sendTransaction(transaction, options) {
|
|
103
|
+
return __async(this, null, function* () {
|
|
104
|
+
const signedTransaction = yield this.signTransaction(transaction);
|
|
105
|
+
return this.connection.sendRawTransaction(signedTransaction.serialize(), options);
|
|
106
|
+
});
|
|
79
107
|
}
|
|
80
108
|
};
|
|
81
109
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/index.js.br
CHANGED
|
Binary file
|
package/dist/cjs/index.js.gz
CHANGED
|
Binary file
|