@getpara/solana-web3.js-v1-integration 1.1.0 → 1.3.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 CHANGED
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./solana-web3js.js"), exports);
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});
Binary file
Binary file
package/dist/esm/index.js CHANGED
@@ -1 +1 @@
1
- export * from './solana-web3js.js';
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};
Binary file
Binary file
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@getpara/solana-web3.js-v1-integration",
3
- "version": "1.1.0",
3
+ "version": "1.3.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.1.0",
10
+ "@getpara/core-sdk": "1.3.0",
11
11
  "@solana/web3.js": "^1.95.8"
12
12
  },
13
13
  "scripts": {
14
- "build": "yarn build:cjs && yarn build:esm && yarn build:types",
14
+ "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
15
+ "old-build": "yarn build:cjs && yarn build:esm && yarn build:types",
15
16
  "build:cjs": "rm -rf dist/cjs && tsc --module commonjs --outDir dist/cjs && printf '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
16
17
  "build:esm": "rm -rf dist/esm && tsc --module es6 --outDir dist/esm && printf '{\"type\":\"module\",\"sideEffects\":false}' > dist/esm/package.json",
17
18
  "build:types": "rm -rf dist/types && tsc --module es6 --declarationDir dist/types --emitDeclarationOnly --declaration"
@@ -30,5 +31,5 @@
30
31
  "types": "./dist/types/index.d.ts"
31
32
  }
32
33
  },
33
- "gitHead": "a9e81f5c4560664441b3a18b3f8fe05c5db927ec"
34
+ "gitHead": "2d421556a0a1497abd08e18dca94f08ec3ad640b"
34
35
  }
@@ -1 +0,0 @@
1
- {"type":"commonjs"}
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.ParaSolanaWeb3Signer = void 0;
39
- const solana = __importStar(require("@solana/web3.js"));
40
- const bs58_1 = __importDefault(require("bs58"));
41
- const core_sdk_1 = require("@getpara/core-sdk");
42
- class ParaSolanaWeb3Signer {
43
- constructor(para, connection, walletId) {
44
- this.currentWalletId = para.findWalletId(walletId, { type: ['SOLANA'] });
45
- this.connection = connection;
46
- this.para = para;
47
- this.address = para.wallets[this.currentWalletId].address;
48
- this.sender = this.address ? new solana.PublicKey(bs58_1.default.decode(this.address)) : undefined;
49
- }
50
- signBytes(bytes) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const res = yield this.para.signMessage({ walletId: this.currentWalletId, messageBase64: bytes.toString('base64') });
53
- if (res.transactionReviewUrl) {
54
- throw new core_sdk_1.TransactionReviewError(res.transactionReviewUrl);
55
- }
56
- return Buffer.from(res.signature, 'base64');
57
- });
58
- }
59
- signTransaction(transaction) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- if (transaction instanceof solana.VersionedTransaction) {
62
- return (yield this.signVersionedTransaction(transaction));
63
- }
64
- if (!transaction.recentBlockhash) {
65
- transaction.recentBlockhash = (yield this.connection.getLatestBlockhash('finalized')).blockhash;
66
- }
67
- const bytesToSign = transaction.serializeMessage();
68
- const sigBytes = yield this.signBytes(bytesToSign);
69
- transaction.addSignature(this.sender, sigBytes);
70
- return transaction;
71
- });
72
- }
73
- signVersionedTransaction(transaction) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- if (!transaction.message.recentBlockhash) {
76
- transaction.message.recentBlockhash = (yield this.connection.getLatestBlockhash('finalized')).blockhash;
77
- }
78
- const messageBytes = transaction.message.serialize();
79
- const sigBytes = yield this.signBytes(Buffer.from(messageBytes));
80
- transaction.addSignature(this.sender, sigBytes);
81
- return transaction;
82
- });
83
- }
84
- sendTransaction(transaction, options) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- const signedTransaction = yield this.signTransaction(transaction);
87
- return this.connection.sendRawTransaction(signedTransaction.serialize(), options);
88
- });
89
- }
90
- }
91
- exports.ParaSolanaWeb3Signer = ParaSolanaWeb3Signer;
@@ -1 +0,0 @@
1
- {"type":"module","sideEffects":false}
@@ -1,61 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import * as solana from '@solana/web3.js';
11
- import bs58 from 'bs58';
12
- import { TransactionReviewError } from '@getpara/core-sdk';
13
- export class ParaSolanaWeb3Signer {
14
- constructor(para, connection, walletId) {
15
- this.currentWalletId = para.findWalletId(walletId, { type: ['SOLANA'] });
16
- this.connection = connection;
17
- this.para = para;
18
- this.address = para.wallets[this.currentWalletId].address;
19
- this.sender = this.address ? new solana.PublicKey(bs58.decode(this.address)) : undefined;
20
- }
21
- signBytes(bytes) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- const res = yield this.para.signMessage({ walletId: this.currentWalletId, messageBase64: bytes.toString('base64') });
24
- if (res.transactionReviewUrl) {
25
- throw new TransactionReviewError(res.transactionReviewUrl);
26
- }
27
- return Buffer.from(res.signature, 'base64');
28
- });
29
- }
30
- signTransaction(transaction) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- if (transaction instanceof solana.VersionedTransaction) {
33
- return (yield this.signVersionedTransaction(transaction));
34
- }
35
- if (!transaction.recentBlockhash) {
36
- transaction.recentBlockhash = (yield this.connection.getLatestBlockhash('finalized')).blockhash;
37
- }
38
- const bytesToSign = transaction.serializeMessage();
39
- const sigBytes = yield this.signBytes(bytesToSign);
40
- transaction.addSignature(this.sender, sigBytes);
41
- return transaction;
42
- });
43
- }
44
- signVersionedTransaction(transaction) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- if (!transaction.message.recentBlockhash) {
47
- transaction.message.recentBlockhash = (yield this.connection.getLatestBlockhash('finalized')).blockhash;
48
- }
49
- const messageBytes = transaction.message.serialize();
50
- const sigBytes = yield this.signBytes(Buffer.from(messageBytes));
51
- transaction.addSignature(this.sender, sigBytes);
52
- return transaction;
53
- });
54
- }
55
- sendTransaction(transaction, options) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- const signedTransaction = yield this.signTransaction(transaction);
58
- return this.connection.sendRawTransaction(signedTransaction.serialize(), options);
59
- });
60
- }
61
- }