@mictonode/widget 0.3.16 → 0.3.18

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.
Files changed (69) hide show
  1. package/.github/FUNDING.yml +3 -3
  2. package/.github/workflows/npm-publish.yml +34 -34
  3. package/.prettierrc.json +9 -9
  4. package/.vscode/extensions.json +3 -3
  5. package/LICENSE +674 -674
  6. package/README.md +41 -41
  7. package/dist/{main-d0e5d1e4.js → main-bbea3e54.js} +155 -153
  8. package/dist/ping-widget.js +2 -2
  9. package/dist/ping-widget.umd.cjs +18 -18
  10. package/dist/{query.lcd-3d4d3495.js → query.lcd-88036522.js} +1 -1
  11. package/dist/{query.rpc.Query-b7807c29.js → query.rpc.Query-3a2b14f8.js} +1 -1
  12. package/dist/{tx.rpc.msg-59c3408a.js → tx.rpc.msg-39f0b824.js} +1 -1
  13. package/example/.vscode/extensions.json +3 -3
  14. package/example/README.md +7 -7
  15. package/example/index.html +12 -12
  16. package/example/package.json +19 -19
  17. package/example/pnpm-lock.yaml +465 -465
  18. package/example/public/cdn.html +19 -19
  19. package/example/src/App.vue +73 -73
  20. package/example/src/main.js +4 -4
  21. package/example/vite.config.js +7 -7
  22. package/index.html +12 -12
  23. package/lib/components/ConnectWallet/index.vue +262 -262
  24. package/lib/components/TokenConvert/index.vue +1033 -1033
  25. package/lib/components/TokenConvert/tokens.ts +36 -36
  26. package/lib/components/TxDialog/index.vue +422 -422
  27. package/lib/components/TxDialog/messages/Delegate.vue +174 -174
  28. package/lib/components/TxDialog/messages/Deposit.vue +96 -96
  29. package/lib/components/TxDialog/messages/Redelegate.vue +160 -160
  30. package/lib/components/TxDialog/messages/Send.vue +142 -142
  31. package/lib/components/TxDialog/messages/Transfer.vue +248 -248
  32. package/lib/components/TxDialog/messages/Unbond.vue +103 -103
  33. package/lib/components/TxDialog/messages/Vote.vue +62 -62
  34. package/lib/components/TxDialog/messages/Withdraw.vue +55 -55
  35. package/lib/components/TxDialog/messages/WithdrawCommission.vue +74 -74
  36. package/lib/components/TxDialog/wasm/ClearAdmin.vue +55 -55
  37. package/lib/components/TxDialog/wasm/ExecuteContract.vue +98 -98
  38. package/lib/components/TxDialog/wasm/InstantiateContract.vue +108 -108
  39. package/lib/components/TxDialog/wasm/MigrateContract.vue +76 -76
  40. package/lib/components/TxDialog/wasm/MigrateContract2.vue +76 -76
  41. package/lib/components/TxDialog/wasm/StoreCode.vue +100 -100
  42. package/lib/components/TxDialog/wasm/UpdateAdmin.vue +74 -74
  43. package/lib/main.css +591 -7
  44. package/lib/main.ts +24 -23
  45. package/lib/utils/TokenUnitConverter.ts +44 -44
  46. package/lib/utils/format.ts +16 -16
  47. package/lib/utils/http.ts +154 -154
  48. package/lib/utils/type.ts +56 -56
  49. package/lib/wallet/EthermintMessageAdapter.ts +135 -135
  50. package/lib/wallet/UniClient.ts +144 -144
  51. package/lib/wallet/Wallet.ts +142 -142
  52. package/lib/wallet/wallets/KeplerWallet.ts +141 -141
  53. package/lib/wallet/wallets/LeapWallet.ts +141 -141
  54. package/lib/wallet/wallets/LedgerWallet.ts +202 -202
  55. package/lib/wallet/wallets/MetamaskSnapWallet.ts +105 -105
  56. package/lib/wallet/wallets/MetamaskWallet.ts +173 -173
  57. package/lib/wallet/wallets/OKXWallet.ts +202 -202
  58. package/lib/wallet/wallets/UnisatWallet.ts +198 -198
  59. package/package.json +5 -6
  60. package/postcss.config.js +6 -6
  61. package/src/App.vue +225 -225
  62. package/src/main.ts +7 -4
  63. package/src/styles/design-system.css +184 -0
  64. package/src/vite-env.d.ts +1 -1
  65. package/tailwind.config.js +158 -34
  66. package/tsconfig.json +25 -25
  67. package/tsconfig.node.json +10 -10
  68. package/vite.config.ts +62 -62
  69. package/vue-shim.d.ts +6 -6
@@ -1,202 +1,202 @@
1
- import { fromBase64, fromHex } from '@cosmjs/encoding';
2
- import { makeAuthInfoBytes, makeSignBytes, makeSignDoc, Registry, TxBodyEncodeObject } from '@cosmjs/proto-signing';
3
-
4
- import { serializeSignDoc } from '@cosmjs/amino/build/signdoc';
5
-
6
- import { AbstractWallet, Account, IChain, WalletArgument, WalletName } from '../Wallet';
7
- import { Transaction } from '../../utils/type';
8
- import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
9
- import { Any } from 'cosmjs-types/google/protobuf/any';
10
- import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys';
11
- import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing';
12
- import { AminoTypes, createDefaultAminoConverters, createIbcAminoConverters } from '@cosmjs/stargate';
13
- import { makeSignDoc as makeSignDocAmino } from '@cosmjs/amino';
14
- import { createWasmAminoConverters } from '@cosmjs/cosmwasm-stargate';
15
- import { Buffer } from 'buffer';
16
-
17
- export class OKXWallet implements AbstractWallet {
18
- name: WalletName.OKX = WalletName.OKX;
19
- chainId: string;
20
- chain: IChain;
21
- registry: Registry;
22
- conf: WalletArgument;
23
- aminoTypes = new AminoTypes({
24
- ...createDefaultAminoConverters(),
25
- ...createIbcAminoConverters(),
26
- ...createWasmAminoConverters(),
27
- });
28
-
29
- connectEventNamesOnWindow: string[] = [];
30
-
31
- constructor(arg: WalletArgument, chain: IChain, registry: Registry) {
32
- this.chainId = arg.chainId || "cosmoshub";
33
- // @ts-ignore
34
-
35
- this.registry = registry;
36
- this.conf = arg;
37
- this.chain = chain;
38
- }
39
- async getAccounts(): Promise<Account[]> {
40
- // @ts-ignore
41
-
42
- if (!window?.okxwallet) {
43
- throw new Error("Please install OKX wallet extension");
44
- }
45
- // @ts-ignore
46
- const connectRes = await window.okxwallet.bitcoin.connect();
47
- console.log("connectRes: ", connectRes);
48
-
49
- // @ts-ignore
50
- const accounts = await window.okxwallet.bitcoin.getAccounts();
51
-
52
- // @ts-ignore
53
- const pbk = await window.okxwallet.bitcoin.getPublicKey();
54
-
55
- return [
56
- {
57
- address: accounts[0],
58
- pubkey: fromHex(pbk),
59
- algo: 'segwit',
60
- },
61
- ];
62
- }
63
- supportCoinType(): Promise<boolean> {
64
- return Promise.resolve(true);
65
- }
66
-
67
- isEthermint() {
68
- return this.conf.hdPath && this.conf.hdPath.startsWith("m/44'/60");
69
- }
70
-
71
- async sign(transaction: Transaction): Promise<TxRaw> {
72
- // return this.signDirect(transaction);
73
- return this.signAmino(transaction);
74
- }
75
- // @deprecated use signAmino instead
76
- // because signDirect is not supported ledger wallet
77
- async signDirect(transaction: Transaction): Promise<TxRaw> {
78
- const accouts = await this.getAccounts();
79
-
80
- const accountFromSigner = accouts[0];
81
- if (!accountFromSigner) {
82
- throw new Error("Failed to retrieve account from signer");
83
- }
84
- const pubkey = Any.fromPartial({
85
- typeUrl: "/cosmos.crypto.segwit.PubKey",
86
- value: PubKey.encode({
87
- key: accountFromSigner.pubkey,
88
- }).finish(),
89
- });
90
-
91
- const txBodyEncodeObject: TxBodyEncodeObject = {
92
- typeUrl: "/cosmos.tx.v1beta1.TxBody",
93
- value: {
94
- messages: transaction.messages,
95
- memo: transaction.memo,
96
- },
97
- };
98
-
99
- const txBodyBytes = this.registry.encode(txBodyEncodeObject);
100
- const gasLimit = Number(transaction.fee.gas);
101
- const authInfoBytes = makeAuthInfoBytes(
102
- [{ pubkey, sequence: transaction.signerData.sequence }],
103
- transaction.fee.amount,
104
- gasLimit,
105
- transaction.fee.granter,
106
- transaction.fee.payer
107
- );
108
-
109
- const signDoc = makeSignDoc(
110
- txBodyBytes,
111
- authInfoBytes,
112
- transaction.chainId,
113
- transaction.signerData.accountNumber
114
- );
115
- console.log("signDoc: ", signDoc);
116
-
117
- const signDocBuffer = makeSignBytes(signDoc);
118
-
119
- const signString = Buffer.from(signDocBuffer).toString();
120
-
121
- // @ts-ignore
122
- const signature = await window.okxwallet.bitcoin.signMessage(
123
- signString,
124
- "ecdsa"
125
- );
126
-
127
- const signed = signDoc;
128
-
129
- return TxRaw.fromPartial({
130
- bodyBytes: signed.bodyBytes,
131
- authInfoBytes: signed.authInfoBytes,
132
- signatures: [fromBase64(signature)],
133
- });
134
- }
135
-
136
- async signAmino(tx: Transaction): Promise<TxRaw> {
137
- const accouts = await this.getAccounts();
138
-
139
- const accountFromSigner = accouts[0];
140
- if (!accountFromSigner) {
141
- throw new Error("Failed to retrieve account from signer");
142
- }
143
- const pubkey = Any.fromPartial({
144
- typeUrl: "/cosmos.crypto.segwit.PubKey",
145
- value: PubKey.encode({
146
- key: accountFromSigner.pubkey,
147
- }).finish(),
148
- });
149
-
150
- const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
151
- const msgs = tx.messages.map((msg) => this.aminoTypes.toAmino(msg));
152
- const signDoc = makeSignDocAmino(
153
- msgs,
154
- tx.fee,
155
- tx.chainId,
156
- tx.memo,
157
- tx.signerData.accountNumber,
158
- tx.signerData.sequence
159
- );
160
-
161
- const signed = signDoc;
162
-
163
- const signDocBuffer = serializeSignDoc(signDoc);
164
-
165
- const signString = Buffer.from(signDocBuffer).toString();
166
-
167
- // @ts-ignore
168
- const signature = await window.okxwallet.bitcoin.signMessage(
169
- signString,
170
- "ecdsa"
171
- );
172
-
173
- const signedTxBody = {
174
- messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
175
- memo: signed.memo,
176
- };
177
-
178
- const signedTxBodyEncodeObject: TxBodyEncodeObject = {
179
- typeUrl: "/cosmos.tx.v1beta1.TxBody",
180
- value: signedTxBody,
181
- };
182
-
183
- const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
184
-
185
- const signedGasLimit = Number(signed.fee.gas);
186
- const signedSequence = Number(signed.sequence);
187
- const signedAuthInfoBytes = makeAuthInfoBytes(
188
- [{ pubkey, sequence: signedSequence }],
189
- signed.fee.amount,
190
- signedGasLimit,
191
- signed.fee.granter,
192
- signed.fee.payer,
193
- signMode
194
- );
195
-
196
- return TxRaw.fromPartial({
197
- bodyBytes: signedTxBodyBytes,
198
- authInfoBytes: signedAuthInfoBytes,
199
- signatures: [fromBase64(signature)],
200
- });
201
- }
202
- }
1
+ import { fromBase64, fromHex } from '@cosmjs/encoding';
2
+ import { makeAuthInfoBytes, makeSignBytes, makeSignDoc, Registry, TxBodyEncodeObject } from '@cosmjs/proto-signing';
3
+
4
+ import { serializeSignDoc } from '@cosmjs/amino/build/signdoc';
5
+
6
+ import { AbstractWallet, Account, IChain, WalletArgument, WalletName } from '../Wallet';
7
+ import { Transaction } from '../../utils/type';
8
+ import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
9
+ import { Any } from 'cosmjs-types/google/protobuf/any';
10
+ import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys';
11
+ import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing';
12
+ import { AminoTypes, createDefaultAminoConverters, createIbcAminoConverters } from '@cosmjs/stargate';
13
+ import { makeSignDoc as makeSignDocAmino } from '@cosmjs/amino';
14
+ import { createWasmAminoConverters } from '@cosmjs/cosmwasm-stargate';
15
+ import { Buffer } from 'buffer';
16
+
17
+ export class OKXWallet implements AbstractWallet {
18
+ name: WalletName.OKX = WalletName.OKX;
19
+ chainId: string;
20
+ chain: IChain;
21
+ registry: Registry;
22
+ conf: WalletArgument;
23
+ aminoTypes = new AminoTypes({
24
+ ...createDefaultAminoConverters(),
25
+ ...createIbcAminoConverters(),
26
+ ...createWasmAminoConverters(),
27
+ });
28
+
29
+ connectEventNamesOnWindow: string[] = [];
30
+
31
+ constructor(arg: WalletArgument, chain: IChain, registry: Registry) {
32
+ this.chainId = arg.chainId || "cosmoshub";
33
+ // @ts-ignore
34
+
35
+ this.registry = registry;
36
+ this.conf = arg;
37
+ this.chain = chain;
38
+ }
39
+ async getAccounts(): Promise<Account[]> {
40
+ // @ts-ignore
41
+
42
+ if (!window?.okxwallet) {
43
+ throw new Error("Please install OKX wallet extension");
44
+ }
45
+ // @ts-ignore
46
+ const connectRes = await window.okxwallet.bitcoin.connect();
47
+ console.log("connectRes: ", connectRes);
48
+
49
+ // @ts-ignore
50
+ const accounts = await window.okxwallet.bitcoin.getAccounts();
51
+
52
+ // @ts-ignore
53
+ const pbk = await window.okxwallet.bitcoin.getPublicKey();
54
+
55
+ return [
56
+ {
57
+ address: accounts[0],
58
+ pubkey: fromHex(pbk),
59
+ algo: 'segwit',
60
+ },
61
+ ];
62
+ }
63
+ supportCoinType(): Promise<boolean> {
64
+ return Promise.resolve(true);
65
+ }
66
+
67
+ isEthermint() {
68
+ return this.conf.hdPath && this.conf.hdPath.startsWith("m/44'/60");
69
+ }
70
+
71
+ async sign(transaction: Transaction): Promise<TxRaw> {
72
+ // return this.signDirect(transaction);
73
+ return this.signAmino(transaction);
74
+ }
75
+ // @deprecated use signAmino instead
76
+ // because signDirect is not supported ledger wallet
77
+ async signDirect(transaction: Transaction): Promise<TxRaw> {
78
+ const accouts = await this.getAccounts();
79
+
80
+ const accountFromSigner = accouts[0];
81
+ if (!accountFromSigner) {
82
+ throw new Error("Failed to retrieve account from signer");
83
+ }
84
+ const pubkey = Any.fromPartial({
85
+ typeUrl: "/cosmos.crypto.segwit.PubKey",
86
+ value: PubKey.encode({
87
+ key: accountFromSigner.pubkey,
88
+ }).finish(),
89
+ });
90
+
91
+ const txBodyEncodeObject: TxBodyEncodeObject = {
92
+ typeUrl: "/cosmos.tx.v1beta1.TxBody",
93
+ value: {
94
+ messages: transaction.messages,
95
+ memo: transaction.memo,
96
+ },
97
+ };
98
+
99
+ const txBodyBytes = this.registry.encode(txBodyEncodeObject);
100
+ const gasLimit = Number(transaction.fee.gas);
101
+ const authInfoBytes = makeAuthInfoBytes(
102
+ [{ pubkey, sequence: transaction.signerData.sequence }],
103
+ transaction.fee.amount,
104
+ gasLimit,
105
+ transaction.fee.granter,
106
+ transaction.fee.payer
107
+ );
108
+
109
+ const signDoc = makeSignDoc(
110
+ txBodyBytes,
111
+ authInfoBytes,
112
+ transaction.chainId,
113
+ transaction.signerData.accountNumber
114
+ );
115
+ console.log("signDoc: ", signDoc);
116
+
117
+ const signDocBuffer = makeSignBytes(signDoc);
118
+
119
+ const signString = Buffer.from(signDocBuffer).toString();
120
+
121
+ // @ts-ignore
122
+ const signature = await window.okxwallet.bitcoin.signMessage(
123
+ signString,
124
+ "ecdsa"
125
+ );
126
+
127
+ const signed = signDoc;
128
+
129
+ return TxRaw.fromPartial({
130
+ bodyBytes: signed.bodyBytes,
131
+ authInfoBytes: signed.authInfoBytes,
132
+ signatures: [fromBase64(signature)],
133
+ });
134
+ }
135
+
136
+ async signAmino(tx: Transaction): Promise<TxRaw> {
137
+ const accouts = await this.getAccounts();
138
+
139
+ const accountFromSigner = accouts[0];
140
+ if (!accountFromSigner) {
141
+ throw new Error("Failed to retrieve account from signer");
142
+ }
143
+ const pubkey = Any.fromPartial({
144
+ typeUrl: "/cosmos.crypto.segwit.PubKey",
145
+ value: PubKey.encode({
146
+ key: accountFromSigner.pubkey,
147
+ }).finish(),
148
+ });
149
+
150
+ const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
151
+ const msgs = tx.messages.map((msg) => this.aminoTypes.toAmino(msg));
152
+ const signDoc = makeSignDocAmino(
153
+ msgs,
154
+ tx.fee,
155
+ tx.chainId,
156
+ tx.memo,
157
+ tx.signerData.accountNumber,
158
+ tx.signerData.sequence
159
+ );
160
+
161
+ const signed = signDoc;
162
+
163
+ const signDocBuffer = serializeSignDoc(signDoc);
164
+
165
+ const signString = Buffer.from(signDocBuffer).toString();
166
+
167
+ // @ts-ignore
168
+ const signature = await window.okxwallet.bitcoin.signMessage(
169
+ signString,
170
+ "ecdsa"
171
+ );
172
+
173
+ const signedTxBody = {
174
+ messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
175
+ memo: signed.memo,
176
+ };
177
+
178
+ const signedTxBodyEncodeObject: TxBodyEncodeObject = {
179
+ typeUrl: "/cosmos.tx.v1beta1.TxBody",
180
+ value: signedTxBody,
181
+ };
182
+
183
+ const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
184
+
185
+ const signedGasLimit = Number(signed.fee.gas);
186
+ const signedSequence = Number(signed.sequence);
187
+ const signedAuthInfoBytes = makeAuthInfoBytes(
188
+ [{ pubkey, sequence: signedSequence }],
189
+ signed.fee.amount,
190
+ signedGasLimit,
191
+ signed.fee.granter,
192
+ signed.fee.payer,
193
+ signMode
194
+ );
195
+
196
+ return TxRaw.fromPartial({
197
+ bodyBytes: signedTxBodyBytes,
198
+ authInfoBytes: signedAuthInfoBytes,
199
+ signatures: [fromBase64(signature)],
200
+ });
201
+ }
202
+ }