@getpara/solana-web3.js-v1-integration 1.4.2 → 1.4.4

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 CHANGED
@@ -1 +1,84 @@
1
- var g=Object.create;var t=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var B=(a,s)=>{for(var e in s)t(a,e,{get:s[e],enumerable:!0})},c=(a,s,e,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let i of f(s))!m.call(a,i)&&i!==e&&t(a,i,{get:()=>s[i],enumerable:!(n=u(s,i))||n.enumerable});return a};var l=(a,s,e)=>(e=a!=null?g(T(a)):{},c(s||!a||!a.__esModule?t(e,"default",{value:a,enumerable:!0}):e,a)),w=a=>c(t({},"__esModule",{value:!0}),a);var y={};B(y,{ParaSolanaWeb3Signer:()=>o});module.exports=w(y);var r=l(require("@solana/web3.js")),d=l(require("bs58")),h=require("@getpara/core-sdk"),o=class{constructor(s,e,n){this.currentWalletId=s.findWalletId(n,{type:["SOLANA"]}),this.connection=e,this.para=s,this.address=s.wallets[this.currentWalletId].address,this.sender=this.address?new r.PublicKey(d.default.decode(this.address)):void 0}async signBytes(s){let e=await this.para.signMessage({walletId:this.currentWalletId,messageBase64:s.toString("base64")});if(e.transactionReviewUrl)throw new h.TransactionReviewError(e.transactionReviewUrl);return Buffer.from(e.signature,"base64")}async signTransaction(s){if(s instanceof r.VersionedTransaction)return await this.signVersionedTransaction(s);s.recentBlockhash||(s.recentBlockhash=(await this.connection.getLatestBlockhash("finalized")).blockhash);let e=s.serializeMessage(),n=await this.signBytes(e);return s.addSignature(this.sender,n),s}async signVersionedTransaction(s){s.message.recentBlockhash||(s.message.recentBlockhash=(await this.connection.getLatestBlockhash("finalized")).blockhash);let e=s.message.serialize(),n=await this.signBytes(Buffer.from(e));return s.addSignature(this.sender,n),s}async sendTransaction(s,e){let n=await this.signTransaction(s);return this.connection.sendRawTransaction(n.serialize(),e)}};0&&(module.exports={ParaSolanaWeb3Signer});
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
+ });
Binary file
Binary file
package/dist/esm/index.js CHANGED
@@ -1 +1,48 @@
1
- import*as n from"@solana/web3.js";import t from"bs58";import{TransactionReviewError as r}from"@getpara/core-sdk";var i=class{constructor(s,e,a){this.currentWalletId=s.findWalletId(a,{type:["SOLANA"]}),this.connection=e,this.para=s,this.address=s.wallets[this.currentWalletId].address,this.sender=this.address?new n.PublicKey(t.decode(this.address)):void 0}async signBytes(s){let e=await this.para.signMessage({walletId:this.currentWalletId,messageBase64:s.toString("base64")});if(e.transactionReviewUrl)throw new r(e.transactionReviewUrl);return Buffer.from(e.signature,"base64")}async signTransaction(s){if(s instanceof n.VersionedTransaction)return await this.signVersionedTransaction(s);s.recentBlockhash||(s.recentBlockhash=(await this.connection.getLatestBlockhash("finalized")).blockhash);let e=s.serializeMessage(),a=await this.signBytes(e);return s.addSignature(this.sender,a),s}async signVersionedTransaction(s){s.message.recentBlockhash||(s.message.recentBlockhash=(await this.connection.getLatestBlockhash("finalized")).blockhash);let e=s.message.serialize(),a=await this.signBytes(Buffer.from(e));return s.addSignature(this.sender,a),s}async sendTransaction(s,e){let a=await this.signTransaction(s);return this.connection.sendRawTransaction(a.serialize(),e)}};export{i as ParaSolanaWeb3Signer};
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
+ };
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@getpara/solana-web3.js-v1-integration",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
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.4.2",
10
+ "@getpara/core-sdk": "1.4.4",
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": "8404d1f8461109347360fe21be6057f826d31cec"
34
+ "gitHead": "9a4086c4b352fff2143d3b931d288c5ebaf127fb"
35
35
  }