@mictonode/widget 0.3.16 → 0.3.17

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-465ae991.js} +151 -149
  8. package/dist/ping-widget.js +2 -2
  9. package/dist/ping-widget.umd.cjs +17 -17
  10. package/dist/{query.lcd-3d4d3495.js → query.lcd-d9c6163c.js} +1 -1
  11. package/dist/{query.rpc.Query-b7807c29.js → query.rpc.Query-a479e6f9.js} +1 -1
  12. package/dist/{tx.rpc.msg-59c3408a.js → tx.rpc.msg-7444045d.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 +8 -8
  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 +132 -7
  44. package/lib/main.ts +23 -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 +3 -3
  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 +150 -0
  64. package/src/vite-env.d.ts +1 -1
  65. package/tailwind.config.js +211 -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,198 +1,198 @@
1
- import { fromBase64, fromHex } from '@cosmjs/encoding';
2
- import { makeAuthInfoBytes, makeSignBytes, makeSignDoc, Registry, TxBodyEncodeObject } from '@cosmjs/proto-signing';
3
-
4
- import { AbstractWallet, Account, IChain, WalletArgument, WalletName } from '../Wallet';
5
- import { Transaction } from '../../utils/type';
6
- import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
7
- import { Any } from 'cosmjs-types/google/protobuf/any';
8
- import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys';
9
- import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing';
10
- import { AminoTypes, createDefaultAminoConverters, createIbcAminoConverters } from '@cosmjs/stargate';
11
- import { makeSignDoc as makeSignDocAmino } from '@cosmjs/amino';
12
- import { createWasmAminoConverters } from '@cosmjs/cosmwasm-stargate';
13
- import { Buffer } from 'buffer';
14
-
15
- import { serializeSignDoc } from '@cosmjs/amino/build/signdoc';
16
-
17
- export class UnisatWallet implements AbstractWallet {
18
- name: WalletName.Unisat = WalletName.Unisat;
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 (typeof window?.unisat === "undefined") {
43
- throw new Error("Please install UniSat wallet extension");
44
- }
45
- // @ts-ignore
46
- await window.unisat.requestAccounts();
47
-
48
- // @ts-ignore
49
- const accounts = await window.unisat.getAccounts();
50
-
51
- // @ts-ignore
52
- const pbk = await window.unisat.getPublicKey();
53
-
54
- return [
55
- {
56
- address: accounts[0],
57
- pubkey: fromHex(pbk),
58
- algo: "segwit",
59
- },
60
- ];
61
- }
62
- supportCoinType(): Promise<boolean> {
63
- return Promise.resolve(true);
64
- }
65
-
66
- isEthermint() {
67
- return this.conf.hdPath && this.conf.hdPath.startsWith("m/44'/60");
68
- }
69
-
70
- async sign(transaction: Transaction): Promise<TxRaw> {
71
- return this.signAmino(transaction);
72
- }
73
- // @deprecated use signAmino instead
74
- // because signDirect is not supported ledger wallet
75
- async signDirect(transaction: Transaction): Promise<TxRaw> {
76
- const accouts = await this.getAccounts();
77
-
78
- const accountFromSigner = accouts[0];
79
- if (!accountFromSigner) {
80
- throw new Error("Failed to retrieve account from signer");
81
- }
82
- const pubkey = Any.fromPartial({
83
- typeUrl: "/cosmos.crypto.segwit.PubKey",
84
- value: PubKey.encode({
85
- key: accountFromSigner.pubkey,
86
- }).finish(),
87
- });
88
-
89
- const txBodyEncodeObject: TxBodyEncodeObject = {
90
- typeUrl: "/cosmos.tx.v1beta1.TxBody",
91
- value: {
92
- messages: transaction.messages,
93
- memo: transaction.memo,
94
- },
95
- };
96
-
97
- const txBodyBytes = this.registry.encode(txBodyEncodeObject);
98
- console.log("txBodyBytes: ", this.registry);
99
- const gasLimit = Number(transaction.fee.gas);
100
- const authInfoBytes = makeAuthInfoBytes(
101
- [{ pubkey, sequence: transaction.signerData.sequence }],
102
- transaction.fee.amount,
103
- gasLimit,
104
- transaction.fee.granter,
105
- transaction.fee.payer
106
- );
107
-
108
- const signDoc = makeSignDoc(
109
- txBodyBytes,
110
- authInfoBytes,
111
- transaction.chainId,
112
- transaction.signerData.accountNumber
113
- );
114
- console.log("signDoc: ", signDoc);
115
-
116
- const signDocBuffer = makeSignBytes(signDoc);
117
-
118
- const signString = new TextDecoder().decode(signDocBuffer);
119
-
120
- // @ts-ignore
121
- const signature = await window.unisat.signMessage(signString);
122
- console.log("result22: ", signature);
123
-
124
- const signed = signDoc;
125
- console.log("signed: ", signed);
126
-
127
- return TxRaw.fromPartial({
128
- bodyBytes: signed.bodyBytes,
129
- authInfoBytes: signed.authInfoBytes,
130
- signatures: [fromBase64(signature)],
131
- });
132
- }
133
-
134
- async signAmino(tx: Transaction): Promise<TxRaw> {
135
- const accouts = await this.getAccounts();
136
-
137
- const accountFromSigner = accouts[0];
138
- if (!accountFromSigner) {
139
- throw new Error("Failed to retrieve account from signer");
140
- }
141
- const pubkey = Any.fromPartial({
142
- typeUrl: "/cosmos.crypto.segwit.PubKey",
143
- value: PubKey.encode({
144
- key: accountFromSigner.pubkey,
145
- }).finish(),
146
- });
147
-
148
- const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
149
- const msgs = tx.messages.map((msg) => this.aminoTypes.toAmino(msg));
150
- const signDoc = makeSignDocAmino(
151
- msgs,
152
- tx.fee,
153
- tx.chainId,
154
- tx.memo,
155
- tx.signerData.accountNumber,
156
- tx.signerData.sequence
157
- );
158
-
159
- const signed = signDoc;
160
-
161
- const signDocBuffer = serializeSignDoc(signDoc);
162
-
163
- const signString = Buffer.from(signDocBuffer).toString();
164
-
165
- // @ts-ignore
166
- const signature = await window.unisat.signMessage(signString);
167
- console.log("signature: ", signature);
168
-
169
- const signedTxBody = {
170
- messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
171
- memo: signed.memo,
172
- };
173
-
174
- const signedTxBodyEncodeObject: TxBodyEncodeObject = {
175
- typeUrl: "/cosmos.tx.v1beta1.TxBody",
176
- value: signedTxBody,
177
- };
178
-
179
- const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
180
-
181
- const signedGasLimit = Number(signed.fee.gas);
182
- const signedSequence = Number(signed.sequence);
183
- const signedAuthInfoBytes = makeAuthInfoBytes(
184
- [{ pubkey, sequence: signedSequence }],
185
- signed.fee.amount,
186
- signedGasLimit,
187
- signed.fee.granter,
188
- signed.fee.payer,
189
- signMode
190
- );
191
-
192
- return TxRaw.fromPartial({
193
- bodyBytes: signedTxBodyBytes,
194
- authInfoBytes: signedAuthInfoBytes,
195
- signatures: [fromBase64(signature)],
196
- });
197
- }
198
- }
1
+ import { fromBase64, fromHex } from '@cosmjs/encoding';
2
+ import { makeAuthInfoBytes, makeSignBytes, makeSignDoc, Registry, TxBodyEncodeObject } from '@cosmjs/proto-signing';
3
+
4
+ import { AbstractWallet, Account, IChain, WalletArgument, WalletName } from '../Wallet';
5
+ import { Transaction } from '../../utils/type';
6
+ import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx';
7
+ import { Any } from 'cosmjs-types/google/protobuf/any';
8
+ import { PubKey } from 'cosmjs-types/cosmos/crypto/secp256k1/keys';
9
+ import { SignMode } from 'cosmjs-types/cosmos/tx/signing/v1beta1/signing';
10
+ import { AminoTypes, createDefaultAminoConverters, createIbcAminoConverters } from '@cosmjs/stargate';
11
+ import { makeSignDoc as makeSignDocAmino } from '@cosmjs/amino';
12
+ import { createWasmAminoConverters } from '@cosmjs/cosmwasm-stargate';
13
+ import { Buffer } from 'buffer';
14
+
15
+ import { serializeSignDoc } from '@cosmjs/amino/build/signdoc';
16
+
17
+ export class UnisatWallet implements AbstractWallet {
18
+ name: WalletName.Unisat = WalletName.Unisat;
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 (typeof window?.unisat === "undefined") {
43
+ throw new Error("Please install UniSat wallet extension");
44
+ }
45
+ // @ts-ignore
46
+ await window.unisat.requestAccounts();
47
+
48
+ // @ts-ignore
49
+ const accounts = await window.unisat.getAccounts();
50
+
51
+ // @ts-ignore
52
+ const pbk = await window.unisat.getPublicKey();
53
+
54
+ return [
55
+ {
56
+ address: accounts[0],
57
+ pubkey: fromHex(pbk),
58
+ algo: "segwit",
59
+ },
60
+ ];
61
+ }
62
+ supportCoinType(): Promise<boolean> {
63
+ return Promise.resolve(true);
64
+ }
65
+
66
+ isEthermint() {
67
+ return this.conf.hdPath && this.conf.hdPath.startsWith("m/44'/60");
68
+ }
69
+
70
+ async sign(transaction: Transaction): Promise<TxRaw> {
71
+ return this.signAmino(transaction);
72
+ }
73
+ // @deprecated use signAmino instead
74
+ // because signDirect is not supported ledger wallet
75
+ async signDirect(transaction: Transaction): Promise<TxRaw> {
76
+ const accouts = await this.getAccounts();
77
+
78
+ const accountFromSigner = accouts[0];
79
+ if (!accountFromSigner) {
80
+ throw new Error("Failed to retrieve account from signer");
81
+ }
82
+ const pubkey = Any.fromPartial({
83
+ typeUrl: "/cosmos.crypto.segwit.PubKey",
84
+ value: PubKey.encode({
85
+ key: accountFromSigner.pubkey,
86
+ }).finish(),
87
+ });
88
+
89
+ const txBodyEncodeObject: TxBodyEncodeObject = {
90
+ typeUrl: "/cosmos.tx.v1beta1.TxBody",
91
+ value: {
92
+ messages: transaction.messages,
93
+ memo: transaction.memo,
94
+ },
95
+ };
96
+
97
+ const txBodyBytes = this.registry.encode(txBodyEncodeObject);
98
+ console.log("txBodyBytes: ", this.registry);
99
+ const gasLimit = Number(transaction.fee.gas);
100
+ const authInfoBytes = makeAuthInfoBytes(
101
+ [{ pubkey, sequence: transaction.signerData.sequence }],
102
+ transaction.fee.amount,
103
+ gasLimit,
104
+ transaction.fee.granter,
105
+ transaction.fee.payer
106
+ );
107
+
108
+ const signDoc = makeSignDoc(
109
+ txBodyBytes,
110
+ authInfoBytes,
111
+ transaction.chainId,
112
+ transaction.signerData.accountNumber
113
+ );
114
+ console.log("signDoc: ", signDoc);
115
+
116
+ const signDocBuffer = makeSignBytes(signDoc);
117
+
118
+ const signString = new TextDecoder().decode(signDocBuffer);
119
+
120
+ // @ts-ignore
121
+ const signature = await window.unisat.signMessage(signString);
122
+ console.log("result22: ", signature);
123
+
124
+ const signed = signDoc;
125
+ console.log("signed: ", signed);
126
+
127
+ return TxRaw.fromPartial({
128
+ bodyBytes: signed.bodyBytes,
129
+ authInfoBytes: signed.authInfoBytes,
130
+ signatures: [fromBase64(signature)],
131
+ });
132
+ }
133
+
134
+ async signAmino(tx: Transaction): Promise<TxRaw> {
135
+ const accouts = await this.getAccounts();
136
+
137
+ const accountFromSigner = accouts[0];
138
+ if (!accountFromSigner) {
139
+ throw new Error("Failed to retrieve account from signer");
140
+ }
141
+ const pubkey = Any.fromPartial({
142
+ typeUrl: "/cosmos.crypto.segwit.PubKey",
143
+ value: PubKey.encode({
144
+ key: accountFromSigner.pubkey,
145
+ }).finish(),
146
+ });
147
+
148
+ const signMode = SignMode.SIGN_MODE_LEGACY_AMINO_JSON;
149
+ const msgs = tx.messages.map((msg) => this.aminoTypes.toAmino(msg));
150
+ const signDoc = makeSignDocAmino(
151
+ msgs,
152
+ tx.fee,
153
+ tx.chainId,
154
+ tx.memo,
155
+ tx.signerData.accountNumber,
156
+ tx.signerData.sequence
157
+ );
158
+
159
+ const signed = signDoc;
160
+
161
+ const signDocBuffer = serializeSignDoc(signDoc);
162
+
163
+ const signString = Buffer.from(signDocBuffer).toString();
164
+
165
+ // @ts-ignore
166
+ const signature = await window.unisat.signMessage(signString);
167
+ console.log("signature: ", signature);
168
+
169
+ const signedTxBody = {
170
+ messages: signed.msgs.map((msg) => this.aminoTypes.fromAmino(msg)),
171
+ memo: signed.memo,
172
+ };
173
+
174
+ const signedTxBodyEncodeObject: TxBodyEncodeObject = {
175
+ typeUrl: "/cosmos.tx.v1beta1.TxBody",
176
+ value: signedTxBody,
177
+ };
178
+
179
+ const signedTxBodyBytes = this.registry.encode(signedTxBodyEncodeObject);
180
+
181
+ const signedGasLimit = Number(signed.fee.gas);
182
+ const signedSequence = Number(signed.sequence);
183
+ const signedAuthInfoBytes = makeAuthInfoBytes(
184
+ [{ pubkey, sequence: signedSequence }],
185
+ signed.fee.amount,
186
+ signedGasLimit,
187
+ signed.fee.granter,
188
+ signed.fee.payer,
189
+ signMode
190
+ );
191
+
192
+ return TxRaw.fromPartial({
193
+ bodyBytes: signedTxBodyBytes,
194
+ authInfoBytes: signedAuthInfoBytes,
195
+ signatures: [fromBase64(signature)],
196
+ });
197
+ }
198
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mictonode/widget",
3
3
  "private": false,
4
- "version": "0.3.16",
4
+ "version": "0.3.17",
5
5
  "type": "module",
6
6
  "main": "dist/ping-widget.js",
7
7
  "author": {
8
- "name": "Alisa | Side Protocol",
9
- "email": "alisa@side.one"
8
+ "name": "MictoNode",
9
+ "email": "info@mictonode.com"
10
10
  },
11
11
  "homepage": "https://github.com/ping-pub/ping-widget",
12
12
  "repository": {
package/postcss.config.js CHANGED
@@ -1,6 +1,6 @@
1
- export default {
2
- plugins: {
3
- tailwindcss: {},
4
- autoprefixer: {},
5
- },
6
- }
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }