@getpara/viem-v1-integration 1.5.0 → 1.5.1
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 +46 -13
- package/dist/cjs/index.js.br +0 -0
- package/dist/cjs/index.js.gz +0 -0
- package/dist/esm/index.js +49 -13
- 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
|
@@ -2,8 +2,22 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
7
21
|
var __export = (target, all) => {
|
|
8
22
|
for (var name in all)
|
|
9
23
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -25,6 +39,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
39
|
mod
|
|
26
40
|
));
|
|
27
41
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
|
+
var __async = (__this, __arguments, generator) => {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
var fulfilled = (value) => {
|
|
45
|
+
try {
|
|
46
|
+
step(generator.next(value));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var rejected = (value) => {
|
|
52
|
+
try {
|
|
53
|
+
step(generator.throw(value));
|
|
54
|
+
} catch (e) {
|
|
55
|
+
reject(e);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
59
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
60
|
+
});
|
|
61
|
+
};
|
|
28
62
|
|
|
29
63
|
// src/index.ts
|
|
30
64
|
var src_exports = {};
|
|
@@ -52,13 +86,13 @@ function createParaAccount(para, walletAddress) {
|
|
|
52
86
|
publicKey: currentWallet.publicKey || "0x",
|
|
53
87
|
source: "custom",
|
|
54
88
|
type: "local",
|
|
55
|
-
signMessage:
|
|
89
|
+
signMessage: (_0) => __async(this, [_0], function* ({ message }) {
|
|
56
90
|
const hashedMessage = (0, import_viem.hashMessage)(message);
|
|
57
|
-
const res =
|
|
91
|
+
const res = yield para.signMessage({ walletId: currentWallet.id, messageBase64: (0, import_core_sdk.hexStringToBase64)(hashedMessage) });
|
|
58
92
|
const signature = res.signature;
|
|
59
93
|
return `0x${signature}`;
|
|
60
|
-
},
|
|
61
|
-
signTransaction:
|
|
94
|
+
}),
|
|
95
|
+
signTransaction: (transaction, args) => __async(this, null, function* () {
|
|
62
96
|
let { serializer } = args || {};
|
|
63
97
|
if (!serializer) {
|
|
64
98
|
serializer = import_viem.serializeTransaction;
|
|
@@ -68,7 +102,7 @@ function createParaAccount(para, walletAddress) {
|
|
|
68
102
|
s: "0x",
|
|
69
103
|
v: BigInt(0)
|
|
70
104
|
});
|
|
71
|
-
const res =
|
|
105
|
+
const res = yield para.signTransaction({
|
|
72
106
|
walletId: currentWallet.id,
|
|
73
107
|
rlpEncodedTxBase64: (0, import_core_sdk.hexStringToBase64)(serializedTx.substring(2)),
|
|
74
108
|
chainId: `${transaction.chainId}`
|
|
@@ -77,15 +111,15 @@ function createParaAccount(para, walletAddress) {
|
|
|
77
111
|
const formattedSig = (0, import_core_sdk.hexToSignature)(`0x${signature}`);
|
|
78
112
|
formattedSig.v += BigInt(27);
|
|
79
113
|
return serializer(transaction, formattedSig);
|
|
80
|
-
},
|
|
81
|
-
signTypedData:
|
|
82
|
-
const res =
|
|
114
|
+
}),
|
|
115
|
+
signTypedData: (typedData) => __async(this, null, function* () {
|
|
116
|
+
const res = yield para.signMessage({
|
|
83
117
|
walletId: currentWallet.id,
|
|
84
118
|
messageBase64: (0, import_core_sdk.hexStringToBase64)((0, import_viem.hashTypedData)(typedData))
|
|
85
119
|
});
|
|
86
120
|
const signature = res.signature;
|
|
87
121
|
return `0x${signature}`;
|
|
88
|
-
}
|
|
122
|
+
})
|
|
89
123
|
};
|
|
90
124
|
}
|
|
91
125
|
function getViemChain(chainId) {
|
|
@@ -98,10 +132,9 @@ function getViemChain(chainId) {
|
|
|
98
132
|
throw new Error(`chain with id ${chainId} not found`);
|
|
99
133
|
}
|
|
100
134
|
function createParaViemClient(para, params, opts) {
|
|
101
|
-
return (0, import_viem.createWalletClient)({
|
|
102
|
-
account: opts
|
|
103
|
-
|
|
104
|
-
});
|
|
135
|
+
return (0, import_viem.createWalletClient)(__spreadValues({
|
|
136
|
+
account: (opts == null ? void 0 : opts.noAccount) ? void 0 : createParaAccount(para)
|
|
137
|
+
}, params));
|
|
105
138
|
}
|
|
106
139
|
// Annotate the CommonJS export names for ESM import in node:
|
|
107
140
|
0 && (module.exports = {
|
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,3 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
1
38
|
// src/viemWalletClient.ts
|
|
2
39
|
import {
|
|
3
40
|
createWalletClient,
|
|
@@ -20,13 +57,13 @@ function createParaAccount(para, walletAddress) {
|
|
|
20
57
|
publicKey: currentWallet.publicKey || "0x",
|
|
21
58
|
source: "custom",
|
|
22
59
|
type: "local",
|
|
23
|
-
signMessage:
|
|
60
|
+
signMessage: (_0) => __async(this, [_0], function* ({ message }) {
|
|
24
61
|
const hashedMessage = hashMessage(message);
|
|
25
|
-
const res =
|
|
62
|
+
const res = yield para.signMessage({ walletId: currentWallet.id, messageBase64: hexStringToBase64(hashedMessage) });
|
|
26
63
|
const signature = res.signature;
|
|
27
64
|
return `0x${signature}`;
|
|
28
|
-
},
|
|
29
|
-
signTransaction:
|
|
65
|
+
}),
|
|
66
|
+
signTransaction: (transaction, args) => __async(this, null, function* () {
|
|
30
67
|
let { serializer } = args || {};
|
|
31
68
|
if (!serializer) {
|
|
32
69
|
serializer = serializeTransaction;
|
|
@@ -36,7 +73,7 @@ function createParaAccount(para, walletAddress) {
|
|
|
36
73
|
s: "0x",
|
|
37
74
|
v: BigInt(0)
|
|
38
75
|
});
|
|
39
|
-
const res =
|
|
76
|
+
const res = yield para.signTransaction({
|
|
40
77
|
walletId: currentWallet.id,
|
|
41
78
|
rlpEncodedTxBase64: hexStringToBase64(serializedTx.substring(2)),
|
|
42
79
|
chainId: `${transaction.chainId}`
|
|
@@ -45,15 +82,15 @@ function createParaAccount(para, walletAddress) {
|
|
|
45
82
|
const formattedSig = hexToSignature(`0x${signature}`);
|
|
46
83
|
formattedSig.v += BigInt(27);
|
|
47
84
|
return serializer(transaction, formattedSig);
|
|
48
|
-
},
|
|
49
|
-
signTypedData:
|
|
50
|
-
const res =
|
|
85
|
+
}),
|
|
86
|
+
signTypedData: (typedData) => __async(this, null, function* () {
|
|
87
|
+
const res = yield para.signMessage({
|
|
51
88
|
walletId: currentWallet.id,
|
|
52
89
|
messageBase64: hexStringToBase64(hashTypedData(typedData))
|
|
53
90
|
});
|
|
54
91
|
const signature = res.signature;
|
|
55
92
|
return `0x${signature}`;
|
|
56
|
-
}
|
|
93
|
+
})
|
|
57
94
|
};
|
|
58
95
|
}
|
|
59
96
|
function getViemChain(chainId) {
|
|
@@ -66,10 +103,9 @@ function getViemChain(chainId) {
|
|
|
66
103
|
throw new Error(`chain with id ${chainId} not found`);
|
|
67
104
|
}
|
|
68
105
|
function createParaViemClient(para, params, opts) {
|
|
69
|
-
return createWalletClient({
|
|
70
|
-
account: opts
|
|
71
|
-
|
|
72
|
-
});
|
|
106
|
+
return createWalletClient(__spreadValues({
|
|
107
|
+
account: (opts == null ? void 0 : opts.noAccount) ? void 0 : createParaAccount(para)
|
|
108
|
+
}, params));
|
|
73
109
|
}
|
|
74
110
|
export {
|
|
75
111
|
createParaAccount,
|
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/viem-v1-integration",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
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.5.
|
|
10
|
+
"@getpara/core-sdk": "1.5.1"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
13
|
"build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"types": "./dist/types/index.d.ts"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
|
|
38
38
|
}
|