hpw-convert-eip681 0.2.0 → 0.4.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/README.md +26 -7
- package/hpw_convert_eip681.d.ts +3 -2
- package/hpw_convert_eip681_bg.js +34 -22
- package/hpw_convert_eip681_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,29 +19,45 @@
|
|
|
19
19
|
|
|
20
20
|
現時点では以下のみに対応しています(他のチェーン・通貨は今後の対応も未定です):
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
22
|
+
- 通貨: **JPYC** のみ
|
|
23
|
+
- チェーン: 下表の4チェーン
|
|
24
|
+
|
|
25
|
+
HashPort Walletの `master_currency_id` は通貨単体ではなく「通貨×チェーン」の組ごとに振られているため、この値からチェーンも決定します。
|
|
26
|
+
|
|
27
|
+
| `master_currency_id` | 通貨 | チェーン | chain id |
|
|
28
|
+
| --- | --- | --- | --- |
|
|
29
|
+
| `487` | JPYC | Polygon | `137` |
|
|
30
|
+
| `489` | JPYC | Avalanche C-Chain | `43114` |
|
|
31
|
+
| `490` | JPYC | Ethereum | `1` |
|
|
32
|
+
| `712` | JPYC | Kaia | `8217` |
|
|
33
|
+
|
|
34
|
+
JPYCのコントラクトアドレスは全チェーン共通(`0xE7C3D8C9a439feDe00D2600032D5dB0Be71C3c29`)のため、EIP-681出力でチェーンごとに変わるのは `@<chain id>` の部分のみです。
|
|
24
35
|
|
|
25
36
|
対応外のURL・チェーン・通貨は `ParseError` (もしくはJS側のタグ付きエラー)として明示的に拒否されます。
|
|
26
37
|
|
|
27
38
|
## 対象とするURL形式
|
|
28
39
|
|
|
29
40
|
```
|
|
30
|
-
https://link.expo2025-wallet.com/pay?to=<address>&master_currency_id
|
|
41
|
+
https://link.expo2025-wallet.com/pay?to=<address>&master_currency_id=<id>&amount=<hex>&to_name=<label>&type=<type>
|
|
31
42
|
```
|
|
32
43
|
|
|
33
44
|
これをEIP-681形式に変換します:
|
|
34
45
|
|
|
35
46
|
```
|
|
36
|
-
ethereum:<JPYC
|
|
47
|
+
ethereum:<JPYCコントラクトアドレス>@<chain id>/transfer?address=<to>&uint256=<amount>
|
|
37
48
|
```
|
|
38
49
|
|
|
39
50
|
`amount` は元URLに存在しないことがあります。その場合 `amount` は
|
|
40
51
|
`None`(JS側では `undefined`)として扱われ、EIP-681出力からも
|
|
41
|
-
`uint256=` パラメータ自体が省かれます(`ethereum:<contract
|
|
52
|
+
`uint256=` パラメータ自体が省かれます(`ethereum:<contract>@<chain id>/transfer?address=<to>`)。これはEIP-681仕様が金額未指定のリクエストを
|
|
42
53
|
許容している(受け取り側のウォレットがユーザーに入力させる)ことに
|
|
43
54
|
対応したものです。
|
|
44
55
|
|
|
56
|
+
`type`(例: `dynamic`)は `to_name` と同様、解釈や検証を加えず生の
|
|
57
|
+
文字列のまま `link_type`(JS側では `linkType`)として保持します。
|
|
58
|
+
取りうる値の全体像が未確認のため、真偽値等には決め打ちしていません。
|
|
59
|
+
パラメータが存在しない場合は `None`(JS側では `undefined`)です。
|
|
60
|
+
|
|
45
61
|
## インストール
|
|
46
62
|
|
|
47
63
|
### Rust (`core`)
|
|
@@ -89,6 +105,9 @@ fn main() {
|
|
|
89
105
|
// まとめて取得することもできる
|
|
90
106
|
let addr_amount = link.address_amount();
|
|
91
107
|
println!("{} / {:?}", addr_amount.address, addr_amount.amount);
|
|
108
|
+
|
|
109
|
+
// to_name / link_type は生のまま(None は「パラメータ自体が無い」)
|
|
110
|
+
println!("to_name: {:?}, link_type: {:?}", link.to_name, link.link_type);
|
|
92
111
|
}
|
|
93
112
|
```
|
|
94
113
|
|
|
@@ -116,8 +135,8 @@ try {
|
|
|
116
135
|
// アドレスと金額を個別に取得する(amountは元URLに無い場合 undefined になる)
|
|
117
136
|
console.log(link.to, link.amount, link.amountHex);
|
|
118
137
|
|
|
119
|
-
//
|
|
120
|
-
console.log(link.chainId, link.currencySymbol, link.currencyContract, link.toName);
|
|
138
|
+
// その他のフィールド(toName/linkType は元URLに無い場合 undefined)
|
|
139
|
+
console.log(link.chainId, link.currencySymbol, link.currencyContract, link.toName, link.linkType);
|
|
121
140
|
} catch (err) {
|
|
122
141
|
console.error(err.kind, err);
|
|
123
142
|
}
|
package/hpw_convert_eip681.d.ts
CHANGED
|
@@ -6,13 +6,14 @@ export class ParsedLink {
|
|
|
6
6
|
free(): void;
|
|
7
7
|
[Symbol.dispose](): void;
|
|
8
8
|
toEip681(): string;
|
|
9
|
-
readonly amount: string | undefined;
|
|
10
9
|
readonly amountHex: string | undefined;
|
|
10
|
+
readonly amount: string | undefined;
|
|
11
11
|
readonly chainId: number;
|
|
12
12
|
readonly currencyContract: string;
|
|
13
13
|
readonly currencySymbol: string;
|
|
14
|
-
readonly
|
|
14
|
+
readonly linkType: string | undefined;
|
|
15
15
|
readonly toName: string | undefined;
|
|
16
|
+
readonly to: string;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export function isSupported(url: string): boolean;
|
package/hpw_convert_eip681_bg.js
CHANGED
|
@@ -18,11 +18,11 @@ export class ParsedLink {
|
|
|
18
18
|
/**
|
|
19
19
|
* @returns {string | undefined}
|
|
20
20
|
*/
|
|
21
|
-
get
|
|
22
|
-
const ret = wasm.
|
|
21
|
+
get amountHex() {
|
|
22
|
+
const ret = wasm.parsedlink_amountHex(this.__wbg_ptr);
|
|
23
23
|
let v1;
|
|
24
24
|
if (ret[0] !== 0) {
|
|
25
|
-
v1 = getStringFromWasm0(ret[0], ret[1])
|
|
25
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
26
26
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
27
27
|
}
|
|
28
28
|
return v1;
|
|
@@ -30,11 +30,11 @@ export class ParsedLink {
|
|
|
30
30
|
/**
|
|
31
31
|
* @returns {string | undefined}
|
|
32
32
|
*/
|
|
33
|
-
get
|
|
34
|
-
const ret = wasm.
|
|
33
|
+
get amount() {
|
|
34
|
+
const ret = wasm.parsedlink_amount(this.__wbg_ptr);
|
|
35
35
|
let v1;
|
|
36
36
|
if (ret[0] !== 0) {
|
|
37
|
-
v1 = getStringFromWasm0(ret[0], ret[1])
|
|
37
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
38
38
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
39
39
|
}
|
|
40
40
|
return v1;
|
|
@@ -77,19 +77,16 @@ export class ParsedLink {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
* @returns {string}
|
|
80
|
+
* @returns {string | undefined}
|
|
81
81
|
*/
|
|
82
|
-
get
|
|
83
|
-
|
|
84
|
-
let
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
deferred1_1 = ret[1];
|
|
89
|
-
return getStringFromWasm0(ret[0], ret[1]);
|
|
90
|
-
} finally {
|
|
91
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
82
|
+
get linkType() {
|
|
83
|
+
const ret = wasm.parsedlink_linkType(this.__wbg_ptr);
|
|
84
|
+
let v1;
|
|
85
|
+
if (ret[0] !== 0) {
|
|
86
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
87
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
92
88
|
}
|
|
89
|
+
return v1;
|
|
93
90
|
}
|
|
94
91
|
/**
|
|
95
92
|
* @returns {string}
|
|
@@ -113,11 +110,26 @@ export class ParsedLink {
|
|
|
113
110
|
const ret = wasm.parsedlink_toName(this.__wbg_ptr);
|
|
114
111
|
let v1;
|
|
115
112
|
if (ret[0] !== 0) {
|
|
116
|
-
v1 = getStringFromWasm0(ret[0], ret[1])
|
|
113
|
+
v1 = getStringFromWasm0(ret[0], ret[1]);
|
|
117
114
|
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
118
115
|
}
|
|
119
116
|
return v1;
|
|
120
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* @returns {string}
|
|
120
|
+
*/
|
|
121
|
+
get to() {
|
|
122
|
+
let deferred1_0;
|
|
123
|
+
let deferred1_1;
|
|
124
|
+
try {
|
|
125
|
+
const ret = wasm.parsedlink_to(this.__wbg_ptr);
|
|
126
|
+
deferred1_0 = ret[0];
|
|
127
|
+
deferred1_1 = ret[1];
|
|
128
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
129
|
+
} finally {
|
|
130
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
121
133
|
}
|
|
122
134
|
if (Symbol.dispose) ParsedLink.prototype[Symbol.dispose] = ParsedLink.prototype.free;
|
|
123
135
|
|
|
@@ -160,10 +172,10 @@ export function parseHashportLink(url) {
|
|
|
160
172
|
export function start() {
|
|
161
173
|
wasm.start();
|
|
162
174
|
}
|
|
163
|
-
export function
|
|
175
|
+
export function __wbg___wbindgen_throw_5d9e815e6fdf150f(arg0, arg1) {
|
|
164
176
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
165
177
|
}
|
|
166
|
-
export function
|
|
178
|
+
export function __wbg_error_757e9472f8410341(arg0, arg1) {
|
|
167
179
|
let deferred0_0;
|
|
168
180
|
let deferred0_1;
|
|
169
181
|
try {
|
|
@@ -178,7 +190,7 @@ export function __wbg_new_227d7c05414eb861() {
|
|
|
178
190
|
const ret = new Error();
|
|
179
191
|
return ret;
|
|
180
192
|
}
|
|
181
|
-
export function
|
|
193
|
+
export function __wbg_new_bebc3f4757acf305() {
|
|
182
194
|
const ret = new Object();
|
|
183
195
|
return ret;
|
|
184
196
|
}
|
|
@@ -192,7 +204,7 @@ export function __wbg_stack_3b0d974bbf31e44f(arg0, arg1) {
|
|
|
192
204
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
193
205
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
194
206
|
}
|
|
195
|
-
export function
|
|
207
|
+
export function __wbindgen_generic_0000000000000001(arg0, arg1) {
|
|
196
208
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
197
209
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
198
210
|
return ret;
|
|
Binary file
|