@mictonode/widget 0.3.9
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/.github/FUNDING.yml +3 -0
- package/.github/workflows/npm-publish.yml +34 -0
- package/.prettierrc.json +9 -0
- package/.vscode/extensions.json +3 -0
- package/README.md +41 -0
- package/dist/main-172a6585.js +404361 -0
- package/dist/ping-widget.js +13 -0
- package/dist/ping-widget.umd.cjs +96 -0
- package/dist/query.lcd-2adf1c0c.js +129 -0
- package/dist/query.rpc.Query-b53908e7.js +2316 -0
- package/dist/tx.rpc.msg-d234ff40.js +37 -0
- package/dist/tx.rpc.msg-f7a80a78.js +21 -0
- package/example/.vscode/extensions.json +3 -0
- package/example/README.md +7 -0
- package/example/index.html +12 -0
- package/example/package.json +19 -0
- package/example/pnpm-lock.yaml +465 -0
- package/example/public/cdn.html +19 -0
- package/example/src/App.vue +73 -0
- package/example/src/main.js +4 -0
- package/example/vite.config.js +7 -0
- package/index.html +12 -0
- package/lib/components/ConnectWallet/index.vue +267 -0
- package/lib/components/TokenConvert/index.vue +1033 -0
- package/lib/components/TokenConvert/tokens.ts +37 -0
- package/lib/components/TxDialog/index.vue +432 -0
- package/lib/components/TxDialog/messages/Delegate.vue +194 -0
- package/lib/components/TxDialog/messages/Deposit.vue +97 -0
- package/lib/components/TxDialog/messages/MsgDelegate.ts +0 -0
- package/lib/components/TxDialog/messages/Redelegate.vue +189 -0
- package/lib/components/TxDialog/messages/Send.vue +142 -0
- package/lib/components/TxDialog/messages/Transfer.vue +248 -0
- package/lib/components/TxDialog/messages/Unbond.vue +137 -0
- package/lib/components/TxDialog/messages/Vote.vue +63 -0
- package/lib/components/TxDialog/messages/Withdraw.vue +56 -0
- package/lib/components/TxDialog/messages/WithdrawCommission.vue +75 -0
- package/lib/components/TxDialog/wasm/ClearAdmin.vue +56 -0
- package/lib/components/TxDialog/wasm/ExecuteContract.vue +99 -0
- package/lib/components/TxDialog/wasm/InstantiateContract.vue +109 -0
- package/lib/components/TxDialog/wasm/MigrateContract.vue +77 -0
- package/lib/components/TxDialog/wasm/MigrateContract2.vue +77 -0
- package/lib/components/TxDialog/wasm/StoreCode.vue +101 -0
- package/lib/components/TxDialog/wasm/UpdateAdmin.vue +75 -0
- package/lib/main.css +7 -0
- package/lib/main.ts +23 -0
- package/lib/utils/TokenUnitConverter.ts +45 -0
- package/lib/utils/format.ts +16 -0
- package/lib/utils/http.ts +223 -0
- package/lib/utils/type.ts +77 -0
- package/lib/wallet/EthermintMessageAdapter.ts +136 -0
- package/lib/wallet/UniClient.ts +152 -0
- package/lib/wallet/Wallet.ts +138 -0
- package/lib/wallet/wallets/InitiaWallet.ts +189 -0
- package/lib/wallet/wallets/KeplerWallet.ts +158 -0
- package/lib/wallet/wallets/LeapWallet.ts +142 -0
- package/lib/wallet/wallets/LedgerWallet.ts +203 -0
- package/lib/wallet/wallets/MetamaskSnapWallet.ts +105 -0
- package/lib/wallet/wallets/MetamaskWallet.ts +173 -0
- package/lib/wallet/wallets/OKXWallet.ts +202 -0
- package/lib/wallet/wallets/UnisatWallet.ts +198 -0
- package/package.json +102 -0
- package/postcss.config.js +6 -0
- package/src/App.vue +241 -0
- package/src/main.ts +4 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +34 -0
- package/tsconfig.json +25 -0
- package/tsconfig.node.json +10 -0
- package/vite.config.ts +62 -0
- package/vue-shim.d.ts +6 -0
package/src/App.vue
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { onMounted, ref } from 'vue';
|
|
3
|
+
import pingWidget from '../lib/main';
|
|
4
|
+
import { ethToEthermint, ethermintToEth } from '../lib/utils/format';
|
|
5
|
+
|
|
6
|
+
// const sender = 'evmos13zl7c4ea60jt05hxhl2dp443r7zrlz4plc5m8z';
|
|
7
|
+
// const endpoint = 'https://api-cosmoshub-ia.cosmosia.notional.ventures'// 'https://rest.stargaze-apis.com';
|
|
8
|
+
// const endpoint = 'https://api.uni.junonetwork.io'
|
|
9
|
+
|
|
10
|
+
interface Config {
|
|
11
|
+
sender: string,
|
|
12
|
+
endpoint: string;
|
|
13
|
+
chainId: string;
|
|
14
|
+
hdPath: string;
|
|
15
|
+
chainName: string
|
|
16
|
+
params: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const INITIA: Config = {
|
|
21
|
+
sender: 'init1vcnp3rf2duwgh45nqxruykw5pcxns7fszy5aje',
|
|
22
|
+
endpoint: 'https://lcd.initiation-1.initia.xyz',
|
|
23
|
+
chainId: 'initiation-1',
|
|
24
|
+
hdPath: "m/44'/118/0'/0/0",
|
|
25
|
+
chainName: 'initia',
|
|
26
|
+
params: JSON.stringify({
|
|
27
|
+
proposal_id: '1',
|
|
28
|
+
validator_address: "initvaloper1vcnp3rf2duwgh45nqxruykw5pcxns7fskpdyuf",
|
|
29
|
+
chain_name: 'initia',
|
|
30
|
+
contract: 'add',
|
|
31
|
+
fees: { amount: '6000000000000000', denom: '', },
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
const EVMOS: Config = {
|
|
37
|
+
sender: 'evmos1ayp22xk4nwc9lhjh6tvdat2j2klnvvk29yx87m',
|
|
38
|
+
endpoint: 'https://rest.bd.evmos.org:1317',
|
|
39
|
+
chainId: 'evmos_9001-2',
|
|
40
|
+
hdPath: "m/44'/60/0'/0/0",
|
|
41
|
+
chainName: 'evmos',
|
|
42
|
+
params: JSON.stringify({
|
|
43
|
+
proposal_id: '1',
|
|
44
|
+
validator_address: "evmosvaloper1tdss4m3x7jy9mlepm2dwy8820l7uv6m2vx6z88",
|
|
45
|
+
chain_name: 'evmos',
|
|
46
|
+
contract: 'add',
|
|
47
|
+
fees: { amount: '6000000000000000', denom: '', },
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
const JUNO: Config = {
|
|
53
|
+
sender: 'juno1m8mma95ta2zajqtmfp5c5y3wgeyqzcrcgcnv4a',
|
|
54
|
+
endpoint: 'https://juno-api.polkachu.com',
|
|
55
|
+
chainId: 'juno-1',
|
|
56
|
+
hdPath: "m/44'/118/0'/0/0",
|
|
57
|
+
chainName: 'juno',
|
|
58
|
+
params: JSON.stringify({
|
|
59
|
+
proposal_id: '1',
|
|
60
|
+
validator_address: "junovaloper1jxv0u20scum4trha72c7ltfgfqef6nscm9pmg2",
|
|
61
|
+
chain_name: 'juno',
|
|
62
|
+
contract: 'junovaloper1jxv0u20scum4trha72c7ltfgfqef6nscm9pmg2',
|
|
63
|
+
fees: {amount: '2000', denom: ''}
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
const NEUTRON: Config = {
|
|
69
|
+
sender: 'neutron1m8mma95ta2zajqtmfp5c5y3wgeyqzcrc64e4gx',
|
|
70
|
+
endpoint: 'https://neutron-api.polkachu.com',
|
|
71
|
+
chainId: 'neutron-1',
|
|
72
|
+
hdPath: "m/44'/118/0'/0/0",
|
|
73
|
+
chainName: 'neutron',
|
|
74
|
+
params: JSON.stringify({
|
|
75
|
+
chain_name: 'neutron',
|
|
76
|
+
contract: 'neutron198sxsrjvt2v2lln2ajn82ks76k97mj72mtgl7309jehd0vy8rezs7e6c56',
|
|
77
|
+
fees: {amount: '2000', denom: ''}
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
const COSMOS: Config = {
|
|
83
|
+
sender: 'cosmos1jxv0u20scum4trha72c7ltfgfqef6nscj25050',
|
|
84
|
+
endpoint: 'https://rest.cosmos.directory/cosmoshub',
|
|
85
|
+
chainId: 'cosmoshub-4',
|
|
86
|
+
hdPath: "m/44'/118/0'/0/0",
|
|
87
|
+
chainName: 'cosmos',
|
|
88
|
+
params: JSON.stringify({
|
|
89
|
+
proposal_id: '1',
|
|
90
|
+
validator_address: "cosmosvaloper1jxv0u20scum4trha72c7ltfgfqef6nsch7q6cu",
|
|
91
|
+
chain_name: 'cosmos',
|
|
92
|
+
contract: 'junovaloper1jxv0u20scum4trha72c7ltfgfqef6nscm9pmg2',
|
|
93
|
+
fees: {amount: '6000', denom: ''}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
const Archway: Config = {
|
|
99
|
+
sender: 'archway1jtdje5vq42sknl22r4wu9sahryu5wcrd3yd7z8',
|
|
100
|
+
endpoint: 'https://api.constantine.archway.tech',
|
|
101
|
+
chainId: 'constantine-3',
|
|
102
|
+
hdPath: "m/44'/118/0'/0/0",
|
|
103
|
+
chainName: 'archway',
|
|
104
|
+
params: JSON.stringify({
|
|
105
|
+
chain_name: 'archway',
|
|
106
|
+
contract: 'archway1tc7k4683zqn8krm3vq7ed5jd4l23c2h9kyswc75zpc8aeln6smqsz79j44',
|
|
107
|
+
fees: {amount: '2000', denom: ''}
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
const btc: Config = {
|
|
113
|
+
sender: 'bc1qjdyxk9t90jxmeqpdwkn8cd7nj6cu7x3m688xlj',
|
|
114
|
+
endpoint: 'https://devnet-2-rest.side.one',
|
|
115
|
+
chainId: 'taproot-1', // side-testnet-1
|
|
116
|
+
hdPath: "m/44'/118/0'/0/0",
|
|
117
|
+
chainName: 'S2-testnet-2',
|
|
118
|
+
params: JSON.stringify({
|
|
119
|
+
// wallet: ['okex', 'unisat']
|
|
120
|
+
// proposal_id: '1',
|
|
121
|
+
// validator_address: "evmosvaloper1tdss4m3x7jy9mlepm2dwy8820l7uv6m2vx6z88",
|
|
122
|
+
// chain_name: 'evmos',
|
|
123
|
+
// contract: 'add',
|
|
124
|
+
// fees: {amount: '6000000000000000', denom: ''}
|
|
125
|
+
})
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
const conf = ref(JUNO)
|
|
130
|
+
// const conf = ref(btc)
|
|
131
|
+
|
|
132
|
+
const types = [
|
|
133
|
+
'send',
|
|
134
|
+
'delegate',
|
|
135
|
+
'vote',
|
|
136
|
+
'redelegate',
|
|
137
|
+
'unbond',
|
|
138
|
+
'transfer',
|
|
139
|
+
'deposit',
|
|
140
|
+
'withdraw',
|
|
141
|
+
'withdraw_commission',
|
|
142
|
+
'wasm_instantiate_contract',
|
|
143
|
+
'wasm_execute_contract',
|
|
144
|
+
'wasm_store_code',
|
|
145
|
+
'wasm_migrate_contract',
|
|
146
|
+
'wasm_update_admin',
|
|
147
|
+
'wasm_clear_admin',
|
|
148
|
+
];
|
|
149
|
+
const toOpen = ref('send');
|
|
150
|
+
|
|
151
|
+
const theme = ref('light');
|
|
152
|
+
const switchTheme = () => {
|
|
153
|
+
if (theme.value === 'light') {
|
|
154
|
+
theme.value = 'dark';
|
|
155
|
+
document.documentElement.classList.add('dark');
|
|
156
|
+
} else {
|
|
157
|
+
theme.value = 'light';
|
|
158
|
+
document.documentElement.classList.remove('dark');
|
|
159
|
+
}
|
|
160
|
+
document.documentElement.setAttribute('data-theme', theme.value);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
onMounted(() => {
|
|
164
|
+
document.documentElement.classList.add('light');
|
|
165
|
+
document.documentElement.setAttribute('data-theme', 'light');
|
|
166
|
+
});
|
|
167
|
+
const walletStateChange = (res: any) => {
|
|
168
|
+
console.log(res, 'resres');
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
console.log("0x88BFec573Dd3E4b7d2E6BfD4D0D6B11F843F8aa1")
|
|
172
|
+
console.log(ethToEthermint("0x88BFec573Dd3E4b7d2E6BfD4D0D6B11F843F8aa1", "evmos"))
|
|
173
|
+
console.log(ethermintToEth("evmos13zl7c4ea60jt05hxhl2dp443r7zrlz4plc5m8z"))
|
|
174
|
+
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
<template>
|
|
178
|
+
<div class="bg-gray-50 dark:bg-base-100 dark:text-white min-h-[100vh]">
|
|
179
|
+
Ping Widget Version: {{ pingWidget?.version }}
|
|
180
|
+
|
|
181
|
+
<div class="btn btn-sm normal-case" @click="switchTheme()">
|
|
182
|
+
Theme: {{ theme }}
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div> </div>
|
|
186
|
+
<ping-connect-wallet
|
|
187
|
+
:chain-id="conf.chainId"
|
|
188
|
+
:hd-path="conf.hdPath"
|
|
189
|
+
@change="walletStateChange"
|
|
190
|
+
/>
|
|
191
|
+
|
|
192
|
+
<textarea v-model="conf.params" cols="80" rows="5"></textarea>
|
|
193
|
+
<div></div>
|
|
194
|
+
|
|
195
|
+
<select v-model="toOpen">
|
|
196
|
+
<option v-for="i in types">{{ i }}</option>
|
|
197
|
+
</select>
|
|
198
|
+
|
|
199
|
+
<br />
|
|
200
|
+
|
|
201
|
+
<label :for="toOpen" class="btn">{{ toOpen }}</label>
|
|
202
|
+
<ping-tx-dialog
|
|
203
|
+
:type="toOpen"
|
|
204
|
+
:sender="conf.sender"
|
|
205
|
+
:registry-name="conf.chainName"
|
|
206
|
+
:endpoint="conf.endpoint"
|
|
207
|
+
:hd-path="conf.hdPath"
|
|
208
|
+
:params="conf.params"
|
|
209
|
+
></ping-tx-dialog>
|
|
210
|
+
|
|
211
|
+
<br />
|
|
212
|
+
// example:<br />
|
|
213
|
+
<label for="withdraw" class="btn">Withdraw</label>
|
|
214
|
+
<ping-tx-dialog
|
|
215
|
+
type="withdraw"
|
|
216
|
+
:sender="conf.sender"
|
|
217
|
+
:endpoint="conf.endpoint"
|
|
218
|
+
:hd-path="conf.hdPath"
|
|
219
|
+
:params="conf.params"
|
|
220
|
+
></ping-tx-dialog>
|
|
221
|
+
|
|
222
|
+
<label for="store_code" class="btn">Store Code</label>
|
|
223
|
+
<ping-tx-dialog
|
|
224
|
+
type="store_code"
|
|
225
|
+
:sender="conf.sender"
|
|
226
|
+
:endpoint="conf.endpoint"
|
|
227
|
+
:registry-name="conf.chainName"
|
|
228
|
+
:hd-path="conf.hdPath"
|
|
229
|
+
:params="conf.params"
|
|
230
|
+
></ping-tx-dialog>
|
|
231
|
+
|
|
232
|
+
<label for="PingTokenConvert" class="btn">Token Convert</label>
|
|
233
|
+
<ping-token-convert
|
|
234
|
+
:chain-name="conf.chainName"
|
|
235
|
+
:endpoint="conf.endpoint"
|
|
236
|
+
hd-path="m/44'/118/0'/0/0"
|
|
237
|
+
></ping-token-convert>
|
|
238
|
+
</div>
|
|
239
|
+
</template>
|
|
240
|
+
|
|
241
|
+
<style scoped></style>
|
package/src/main.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
export default {
|
|
3
|
+
darkMode: ['class'],
|
|
4
|
+
content: [
|
|
5
|
+
'./index.html',
|
|
6
|
+
'./src/**/*.{vue,js,ts,jsx,tsx}',
|
|
7
|
+
'./lib/**/*.{vue,js,ts,jsx,tsx}',
|
|
8
|
+
],
|
|
9
|
+
theme: {
|
|
10
|
+
extend: {},
|
|
11
|
+
},
|
|
12
|
+
plugins: [require('daisyui')],
|
|
13
|
+
daisyui: {
|
|
14
|
+
themes: [
|
|
15
|
+
{
|
|
16
|
+
light: {
|
|
17
|
+
...require('daisyui/src/theming/themes')[
|
|
18
|
+
'[data-theme=light]'
|
|
19
|
+
],
|
|
20
|
+
primary: '#666cff',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
dark: {
|
|
25
|
+
...require('daisyui/src/theming/themes')[
|
|
26
|
+
'[data-theme=dark]'
|
|
27
|
+
],
|
|
28
|
+
primary: '#666cff',
|
|
29
|
+
'base-100': '#2a334c',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "preserve",
|
|
16
|
+
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
|
24
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
25
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import vue from '@vitejs/plugin-vue';
|
|
5
|
+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js';
|
|
6
|
+
import { NodeGlobalsPolyfillPlugin } from '@esbuild-plugins/node-globals-polyfill';
|
|
7
|
+
import nodePolyfills from 'rollup-plugin-polyfill-node';
|
|
8
|
+
import inject from '@rollup/plugin-inject';
|
|
9
|
+
|
|
10
|
+
// https://vitejs.dev/config/
|
|
11
|
+
export default defineConfig({
|
|
12
|
+
plugins: [vue(), cssInjectedByJsPlugin()],
|
|
13
|
+
resolve: {
|
|
14
|
+
preserveSymlinks: true,
|
|
15
|
+
alias: {
|
|
16
|
+
path: 'path-browserify',
|
|
17
|
+
stream: 'stream-browserify',
|
|
18
|
+
crypto: 'crypto-browserify',
|
|
19
|
+
assert: 'assert-browserify',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
optimizeDeps: {
|
|
23
|
+
force: true,
|
|
24
|
+
|
|
25
|
+
esbuildOptions: {
|
|
26
|
+
target: ['es2020'],
|
|
27
|
+
define: {
|
|
28
|
+
global: 'globalThis',
|
|
29
|
+
},
|
|
30
|
+
plugins: [
|
|
31
|
+
NodeGlobalsPolyfillPlugin({
|
|
32
|
+
process: true,
|
|
33
|
+
buffer: true,
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
build: {
|
|
39
|
+
lib: {
|
|
40
|
+
// Could also be a dictionary or array of multiple entry points
|
|
41
|
+
entry: resolve(__dirname, 'lib/main.ts'),
|
|
42
|
+
name: 'ping-widget',
|
|
43
|
+
// the proper extensions will be added
|
|
44
|
+
fileName: 'ping-widget',
|
|
45
|
+
},
|
|
46
|
+
commonjsOptions: {
|
|
47
|
+
transformMixedEsModules: true,
|
|
48
|
+
},
|
|
49
|
+
rollupOptions: {
|
|
50
|
+
output: {
|
|
51
|
+
manualChunks: undefined,
|
|
52
|
+
},
|
|
53
|
+
plugins: [
|
|
54
|
+
nodePolyfills({
|
|
55
|
+
process: true,
|
|
56
|
+
buffer: true,
|
|
57
|
+
}),
|
|
58
|
+
inject({ Buffer: ['buffer', 'Buffer'] }),
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|