@getpara/solana-web3.js-v1-integration 1.4.3 → 1.5.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 +84 -1
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +48 -1
- package/dist/esm/index.js.br +0 -0
- package/dist/esm/index.js.gz +0 -0
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
-
var
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/index.ts
|
|
30
|
+
var src_exports = {};
|
|
31
|
+
__export(src_exports, {
|
|
32
|
+
ParaSolanaWeb3Signer: () => ParaSolanaWeb3Signer
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(src_exports);
|
|
35
|
+
|
|
36
|
+
// src/solana-web3js.ts
|
|
37
|
+
var solana = __toESM(require("@solana/web3.js"));
|
|
38
|
+
var import_bs58 = __toESM(require("bs58"));
|
|
39
|
+
var import_core_sdk = require("@getpara/core-sdk");
|
|
40
|
+
var ParaSolanaWeb3Signer = class {
|
|
41
|
+
constructor(para, connection, walletId) {
|
|
42
|
+
this.currentWalletId = para.findWalletId(walletId, { type: ["SOLANA"] });
|
|
43
|
+
this.connection = connection;
|
|
44
|
+
this.para = para;
|
|
45
|
+
this.address = para.wallets[this.currentWalletId].address;
|
|
46
|
+
this.sender = this.address ? new solana.PublicKey(import_bs58.default.decode(this.address)) : void 0;
|
|
47
|
+
}
|
|
48
|
+
async signBytes(bytes) {
|
|
49
|
+
const res = await this.para.signMessage({ walletId: this.currentWalletId, messageBase64: bytes.toString("base64") });
|
|
50
|
+
if (res.transactionReviewUrl) {
|
|
51
|
+
throw new import_core_sdk.TransactionReviewError(res.transactionReviewUrl);
|
|
52
|
+
}
|
|
53
|
+
return Buffer.from(res.signature, "base64");
|
|
54
|
+
}
|
|
55
|
+
async signTransaction(transaction) {
|
|
56
|
+
if (transaction instanceof solana.VersionedTransaction) {
|
|
57
|
+
return await this.signVersionedTransaction(transaction);
|
|
58
|
+
}
|
|
59
|
+
if (!transaction.recentBlockhash) {
|
|
60
|
+
transaction.recentBlockhash = (await this.connection.getLatestBlockhash("finalized")).blockhash;
|
|
61
|
+
}
|
|
62
|
+
const bytesToSign = transaction.serializeMessage();
|
|
63
|
+
const sigBytes = await this.signBytes(bytesToSign);
|
|
64
|
+
transaction.addSignature(this.sender, sigBytes);
|
|
65
|
+
return transaction;
|
|
66
|
+
}
|
|
67
|
+
async signVersionedTransaction(transaction) {
|
|
68
|
+
if (!transaction.message.recentBlockhash) {
|
|
69
|
+
transaction.message.recentBlockhash = (await this.connection.getLatestBlockhash("finalized")).blockhash;
|
|
70
|
+
}
|
|
71
|
+
const messageBytes = transaction.message.serialize();
|
|
72
|
+
const sigBytes = await this.signBytes(Buffer.from(messageBytes));
|
|
73
|
+
transaction.addSignature(this.sender, sigBytes);
|
|
74
|
+
return transaction;
|
|
75
|
+
}
|
|
76
|
+
async sendTransaction(transaction, options) {
|
|
77
|
+
const signedTransaction = await this.signTransaction(transaction);
|
|
78
|
+
return this.connection.sendRawTransaction(signedTransaction.serialize(), options);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
ParaSolanaWeb3Signer
|
|
84
|
+
});
|
package/dist/cjs/index.js.br
CHANGED
|
Binary file
|
package/dist/cjs/index.js.gz
CHANGED
|
Binary file
|
package/dist/esm/index.js
CHANGED
|
@@ -1 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
// src/solana-web3js.ts
|
|
2
|
+
import * as solana from "@solana/web3.js";
|
|
3
|
+
import bs58 from "bs58";
|
|
4
|
+
import { TransactionReviewError } from "@getpara/core-sdk";
|
|
5
|
+
var ParaSolanaWeb3Signer = class {
|
|
6
|
+
constructor(para, connection, walletId) {
|
|
7
|
+
this.currentWalletId = para.findWalletId(walletId, { type: ["SOLANA"] });
|
|
8
|
+
this.connection = connection;
|
|
9
|
+
this.para = para;
|
|
10
|
+
this.address = para.wallets[this.currentWalletId].address;
|
|
11
|
+
this.sender = this.address ? new solana.PublicKey(bs58.decode(this.address)) : void 0;
|
|
12
|
+
}
|
|
13
|
+
async signBytes(bytes) {
|
|
14
|
+
const res = await this.para.signMessage({ walletId: this.currentWalletId, messageBase64: bytes.toString("base64") });
|
|
15
|
+
if (res.transactionReviewUrl) {
|
|
16
|
+
throw new TransactionReviewError(res.transactionReviewUrl);
|
|
17
|
+
}
|
|
18
|
+
return Buffer.from(res.signature, "base64");
|
|
19
|
+
}
|
|
20
|
+
async signTransaction(transaction) {
|
|
21
|
+
if (transaction instanceof solana.VersionedTransaction) {
|
|
22
|
+
return await this.signVersionedTransaction(transaction);
|
|
23
|
+
}
|
|
24
|
+
if (!transaction.recentBlockhash) {
|
|
25
|
+
transaction.recentBlockhash = (await this.connection.getLatestBlockhash("finalized")).blockhash;
|
|
26
|
+
}
|
|
27
|
+
const bytesToSign = transaction.serializeMessage();
|
|
28
|
+
const sigBytes = await this.signBytes(bytesToSign);
|
|
29
|
+
transaction.addSignature(this.sender, sigBytes);
|
|
30
|
+
return transaction;
|
|
31
|
+
}
|
|
32
|
+
async signVersionedTransaction(transaction) {
|
|
33
|
+
if (!transaction.message.recentBlockhash) {
|
|
34
|
+
transaction.message.recentBlockhash = (await this.connection.getLatestBlockhash("finalized")).blockhash;
|
|
35
|
+
}
|
|
36
|
+
const messageBytes = transaction.message.serialize();
|
|
37
|
+
const sigBytes = await this.signBytes(Buffer.from(messageBytes));
|
|
38
|
+
transaction.addSignature(this.sender, sigBytes);
|
|
39
|
+
return transaction;
|
|
40
|
+
}
|
|
41
|
+
async sendTransaction(transaction, options) {
|
|
42
|
+
const signedTransaction = await this.signTransaction(transaction);
|
|
43
|
+
return this.connection.sendRawTransaction(signedTransaction.serialize(), options);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
ParaSolanaWeb3Signer
|
|
48
|
+
};
|
package/dist/esm/index.js.br
CHANGED
|
Binary file
|
package/dist/esm/index.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/solana-web3.js-v1-integration",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
7
7
|
"typings": "dist/types/index.d.ts",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@getpara/core-sdk": "1.
|
|
10
|
+
"@getpara/core-sdk": "1.5.0",
|
|
11
11
|
"@solana/web3.js": "^1.95.8"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"types": "./dist/types/index.d.ts"
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "0e3c1401b4f1da60b288cdde7695077c9bcbc48f"
|
|
35
35
|
}
|