@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.
- package/.github/FUNDING.yml +3 -3
- package/.github/workflows/npm-publish.yml +34 -34
- package/.prettierrc.json +9 -9
- package/.vscode/extensions.json +3 -3
- package/LICENSE +674 -674
- package/README.md +41 -41
- package/dist/{main-d0e5d1e4.js → main-bbea3e54.js} +155 -153
- package/dist/ping-widget.js +2 -2
- package/dist/ping-widget.umd.cjs +18 -18
- package/dist/{query.lcd-3d4d3495.js → query.lcd-88036522.js} +1 -1
- package/dist/{query.rpc.Query-b7807c29.js → query.rpc.Query-3a2b14f8.js} +1 -1
- package/dist/{tx.rpc.msg-59c3408a.js → tx.rpc.msg-39f0b824.js} +1 -1
- package/example/.vscode/extensions.json +3 -3
- package/example/README.md +7 -7
- package/example/index.html +12 -12
- package/example/package.json +19 -19
- package/example/pnpm-lock.yaml +465 -465
- package/example/public/cdn.html +19 -19
- package/example/src/App.vue +73 -73
- package/example/src/main.js +4 -4
- package/example/vite.config.js +7 -7
- package/index.html +12 -12
- package/lib/components/ConnectWallet/index.vue +262 -262
- package/lib/components/TokenConvert/index.vue +1033 -1033
- package/lib/components/TokenConvert/tokens.ts +36 -36
- package/lib/components/TxDialog/index.vue +422 -422
- package/lib/components/TxDialog/messages/Delegate.vue +174 -174
- package/lib/components/TxDialog/messages/Deposit.vue +96 -96
- package/lib/components/TxDialog/messages/Redelegate.vue +160 -160
- package/lib/components/TxDialog/messages/Send.vue +142 -142
- package/lib/components/TxDialog/messages/Transfer.vue +248 -248
- package/lib/components/TxDialog/messages/Unbond.vue +103 -103
- package/lib/components/TxDialog/messages/Vote.vue +62 -62
- package/lib/components/TxDialog/messages/Withdraw.vue +55 -55
- package/lib/components/TxDialog/messages/WithdrawCommission.vue +74 -74
- package/lib/components/TxDialog/wasm/ClearAdmin.vue +55 -55
- package/lib/components/TxDialog/wasm/ExecuteContract.vue +98 -98
- package/lib/components/TxDialog/wasm/InstantiateContract.vue +108 -108
- package/lib/components/TxDialog/wasm/MigrateContract.vue +76 -76
- package/lib/components/TxDialog/wasm/MigrateContract2.vue +76 -76
- package/lib/components/TxDialog/wasm/StoreCode.vue +100 -100
- package/lib/components/TxDialog/wasm/UpdateAdmin.vue +74 -74
- package/lib/main.css +591 -7
- package/lib/main.ts +24 -23
- package/lib/utils/TokenUnitConverter.ts +44 -44
- package/lib/utils/format.ts +16 -16
- package/lib/utils/http.ts +154 -154
- package/lib/utils/type.ts +56 -56
- package/lib/wallet/EthermintMessageAdapter.ts +135 -135
- package/lib/wallet/UniClient.ts +144 -144
- package/lib/wallet/Wallet.ts +142 -142
- package/lib/wallet/wallets/KeplerWallet.ts +141 -141
- package/lib/wallet/wallets/LeapWallet.ts +141 -141
- package/lib/wallet/wallets/LedgerWallet.ts +202 -202
- package/lib/wallet/wallets/MetamaskSnapWallet.ts +105 -105
- package/lib/wallet/wallets/MetamaskWallet.ts +173 -173
- package/lib/wallet/wallets/OKXWallet.ts +202 -202
- package/lib/wallet/wallets/UnisatWallet.ts +198 -198
- package/package.json +5 -6
- package/postcss.config.js +6 -6
- package/src/App.vue +225 -225
- package/src/main.ts +7 -4
- package/src/styles/design-system.css +184 -0
- package/src/vite-env.d.ts +1 -1
- package/tailwind.config.js +158 -34
- package/tsconfig.json +25 -25
- package/tsconfig.node.json +10 -10
- package/vite.config.ts +62 -62
- package/vue-shim.d.ts +6 -6
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { computed, ref } from 'vue';
|
|
3
|
-
import { toBase64 } from '@cosmjs/encoding'
|
|
4
|
-
|
|
5
|
-
const props = defineProps({
|
|
6
|
-
endpoint: { type: String, required: true },
|
|
7
|
-
sender: { type: String, required: true },
|
|
8
|
-
params: String,
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
12
|
-
|
|
13
|
-
const msgs = computed(() => {
|
|
14
|
-
return [{
|
|
15
|
-
typeUrl: '/cosmwasm.wasm.v1.MsgClearAdmin',
|
|
16
|
-
value: {
|
|
17
|
-
/** Sender is the that actor that signed the messages */
|
|
18
|
-
sender: props.sender,
|
|
19
|
-
/** contract address that can execute migrations */
|
|
20
|
-
contract: params.value.contract,
|
|
21
|
-
},
|
|
22
|
-
}]
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
const isValid = computed(() => {
|
|
26
|
-
let ok = true
|
|
27
|
-
let error = ""
|
|
28
|
-
if( !params.value.contract) {
|
|
29
|
-
ok = false
|
|
30
|
-
error = "Code Id is not selected"
|
|
31
|
-
}
|
|
32
|
-
return { ok, error }
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
function initial() {
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
defineExpose({msgs, isValid, initial})
|
|
39
|
-
|
|
40
|
-
</script>
|
|
41
|
-
<template>
|
|
42
|
-
<div>
|
|
43
|
-
<div class="form-control">
|
|
44
|
-
<label class="label">
|
|
45
|
-
<span class="label-text">Sender</span>
|
|
46
|
-
</label>
|
|
47
|
-
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border
|
|
48
|
-
</div>
|
|
49
|
-
<div class="form-control">
|
|
50
|
-
<label class="label">
|
|
51
|
-
<span class="label-text">Contract Address</span>
|
|
52
|
-
</label>
|
|
53
|
-
<input type="text" readonly class="text-gray-600 dark:text-white input border
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
import { toBase64 } from '@cosmjs/encoding'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
endpoint: { type: String, required: true },
|
|
7
|
+
sender: { type: String, required: true },
|
|
8
|
+
params: String,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
12
|
+
|
|
13
|
+
const msgs = computed(() => {
|
|
14
|
+
return [{
|
|
15
|
+
typeUrl: '/cosmwasm.wasm.v1.MsgClearAdmin',
|
|
16
|
+
value: {
|
|
17
|
+
/** Sender is the that actor that signed the messages */
|
|
18
|
+
sender: props.sender,
|
|
19
|
+
/** contract address that can execute migrations */
|
|
20
|
+
contract: params.value.contract,
|
|
21
|
+
},
|
|
22
|
+
}]
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const isValid = computed(() => {
|
|
26
|
+
let ok = true
|
|
27
|
+
let error = ""
|
|
28
|
+
if( !params.value.contract) {
|
|
29
|
+
ok = false
|
|
30
|
+
error = "Code Id is not selected"
|
|
31
|
+
}
|
|
32
|
+
return { ok, error }
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
function initial() {
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
defineExpose({msgs, isValid, initial})
|
|
39
|
+
|
|
40
|
+
</script>
|
|
41
|
+
<template>
|
|
42
|
+
<div>
|
|
43
|
+
<div class="form-control">
|
|
44
|
+
<label class="label">
|
|
45
|
+
<span class="label-text">Sender</span>
|
|
46
|
+
</label>
|
|
47
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border" />
|
|
48
|
+
</div>
|
|
49
|
+
<div class="form-control">
|
|
50
|
+
<label class="label">
|
|
51
|
+
<span class="label-text">Contract Address</span>
|
|
52
|
+
</label>
|
|
53
|
+
<input type="text" readonly class="text-gray-600 dark:text-white input border" :value="params.contract" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
56
|
</template>
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { Coin } from '@cosmjs/amino';
|
|
3
|
-
import { PropType, computed, ref } from 'vue';
|
|
4
|
-
import type { CoinMetadata } from '../../../utils/type';
|
|
5
|
-
|
|
6
|
-
const props = defineProps({
|
|
7
|
-
endpoint: { type: String, required: true },
|
|
8
|
-
sender: { type: String, required: true },
|
|
9
|
-
balances: Object as PropType<Coin[]>,
|
|
10
|
-
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
11
|
-
params: String,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const parsed = computed(() => JSON.parse(props.params || "{}"))
|
|
15
|
-
|
|
16
|
-
const contract = ref(parsed.value.contract)
|
|
17
|
-
const funds = ref([] as Coin[])
|
|
18
|
-
const msg = ref("")
|
|
19
|
-
|
|
20
|
-
function addFunds() {
|
|
21
|
-
const denom = props.balances?.at(0)?.denom || ""
|
|
22
|
-
funds.value.push({ amount: "", denom })
|
|
23
|
-
}
|
|
24
|
-
function removeFunds() {
|
|
25
|
-
if(funds.value.length > 0)
|
|
26
|
-
funds.value.pop()
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const msgs = computed(() => {
|
|
30
|
-
return [{
|
|
31
|
-
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
|
32
|
-
value: {
|
|
33
|
-
/** Sender is the that actor that signed the messages */
|
|
34
|
-
sender: props.sender,
|
|
35
|
-
contract: contract.value,
|
|
36
|
-
/** Msg json encoded message to be passed to the contract on instantiation */
|
|
37
|
-
msg: (new TextEncoder()).encode(msg.value),
|
|
38
|
-
/** Funds coins that are transferred to the contract on instantiation */
|
|
39
|
-
funds: JSON.parse(JSON.stringify(funds.value)),
|
|
40
|
-
},
|
|
41
|
-
}]
|
|
42
|
-
})
|
|
43
|
-
const isValid = computed(() => {
|
|
44
|
-
let ok = true
|
|
45
|
-
let error = ""
|
|
46
|
-
if( contract.value.length <= 0 ) {
|
|
47
|
-
ok = false
|
|
48
|
-
error = "Contract is not selected"
|
|
49
|
-
}
|
|
50
|
-
if( msg.value.length <= 0 ) {
|
|
51
|
-
ok = false
|
|
52
|
-
error = "Please input arguments"
|
|
53
|
-
}
|
|
54
|
-
return { ok, error }
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
function initial() {
|
|
58
|
-
msg.value = JSON.stringify(parsed.value.execution) || ""
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
defineExpose({msgs, isValid, initial})
|
|
62
|
-
</script>
|
|
63
|
-
<template>
|
|
64
|
-
<div>
|
|
65
|
-
<div class="form-control">
|
|
66
|
-
<label class="label">
|
|
67
|
-
<span class="label-text">Sender</span>
|
|
68
|
-
</label>
|
|
69
|
-
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border
|
|
70
|
-
</div>
|
|
71
|
-
<div class="form-control">
|
|
72
|
-
<label class="label">
|
|
73
|
-
<span class="label-text">Contract Address</span>
|
|
74
|
-
</label>
|
|
75
|
-
<input v-model="contract" type="text" class="text-gray-600 dark:text-white input border
|
|
76
|
-
</div>
|
|
77
|
-
<div class="form-control">
|
|
78
|
-
<label class="label">
|
|
79
|
-
<span class="label-text">Messages</span>
|
|
80
|
-
</label>
|
|
81
|
-
<textarea v-model="msg" placeholder="{config: {}}" class="textarea text-gray-800 dark:text-white
|
|
82
|
-
</div>
|
|
83
|
-
<div class="form-control">
|
|
84
|
-
<label class="label">
|
|
85
|
-
<span class="label-text">Funds</span>
|
|
86
|
-
<span class="label-text">
|
|
87
|
-
<a class="btn btn-xs" @click="addFunds">+</a>
|
|
88
|
-
<a class="btn btn-xs" @click="removeFunds">-</a>
|
|
89
|
-
</span>
|
|
90
|
-
</label>
|
|
91
|
-
<label v-for="(coin, i) in funds" class="input-group" :key="i">
|
|
92
|
-
<input v-model="coin.amount" type="text" placeholder="0" class="input border
|
|
93
|
-
<select v-model="coin.denom" class="select border
|
|
94
|
-
<option v-for="b in balances" :value="b.denom">{{ b.denom.substring(0, 10) }}</option>
|
|
95
|
-
</select>
|
|
96
|
-
</label>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Coin } from '@cosmjs/amino';
|
|
3
|
+
import { PropType, computed, ref } from 'vue';
|
|
4
|
+
import type { CoinMetadata } from '../../../utils/type';
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
endpoint: { type: String, required: true },
|
|
8
|
+
sender: { type: String, required: true },
|
|
9
|
+
balances: Object as PropType<Coin[]>,
|
|
10
|
+
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
11
|
+
params: String,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const parsed = computed(() => JSON.parse(props.params || "{}"))
|
|
15
|
+
|
|
16
|
+
const contract = ref(parsed.value.contract)
|
|
17
|
+
const funds = ref([] as Coin[])
|
|
18
|
+
const msg = ref("")
|
|
19
|
+
|
|
20
|
+
function addFunds() {
|
|
21
|
+
const denom = props.balances?.at(0)?.denom || ""
|
|
22
|
+
funds.value.push({ amount: "", denom })
|
|
23
|
+
}
|
|
24
|
+
function removeFunds() {
|
|
25
|
+
if(funds.value.length > 0)
|
|
26
|
+
funds.value.pop()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const msgs = computed(() => {
|
|
30
|
+
return [{
|
|
31
|
+
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
|
|
32
|
+
value: {
|
|
33
|
+
/** Sender is the that actor that signed the messages */
|
|
34
|
+
sender: props.sender,
|
|
35
|
+
contract: contract.value,
|
|
36
|
+
/** Msg json encoded message to be passed to the contract on instantiation */
|
|
37
|
+
msg: (new TextEncoder()).encode(msg.value),
|
|
38
|
+
/** Funds coins that are transferred to the contract on instantiation */
|
|
39
|
+
funds: JSON.parse(JSON.stringify(funds.value)),
|
|
40
|
+
},
|
|
41
|
+
}]
|
|
42
|
+
})
|
|
43
|
+
const isValid = computed(() => {
|
|
44
|
+
let ok = true
|
|
45
|
+
let error = ""
|
|
46
|
+
if( contract.value.length <= 0 ) {
|
|
47
|
+
ok = false
|
|
48
|
+
error = "Contract is not selected"
|
|
49
|
+
}
|
|
50
|
+
if( msg.value.length <= 0 ) {
|
|
51
|
+
ok = false
|
|
52
|
+
error = "Please input arguments"
|
|
53
|
+
}
|
|
54
|
+
return { ok, error }
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
function initial() {
|
|
58
|
+
msg.value = JSON.stringify(parsed.value.execution) || ""
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
defineExpose({msgs, isValid, initial})
|
|
62
|
+
</script>
|
|
63
|
+
<template>
|
|
64
|
+
<div>
|
|
65
|
+
<div class="form-control">
|
|
66
|
+
<label class="label">
|
|
67
|
+
<span class="label-text">Sender</span>
|
|
68
|
+
</label>
|
|
69
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border" />
|
|
70
|
+
</div>
|
|
71
|
+
<div class="form-control">
|
|
72
|
+
<label class="label">
|
|
73
|
+
<span class="label-text">Contract Address</span>
|
|
74
|
+
</label>
|
|
75
|
+
<input v-model="contract" type="text" class="text-gray-600 dark:text-white input border" />
|
|
76
|
+
</div>
|
|
77
|
+
<div class="form-control">
|
|
78
|
+
<label class="label">
|
|
79
|
+
<span class="label-text">Messages</span>
|
|
80
|
+
</label>
|
|
81
|
+
<textarea v-model="msg" placeholder="{config: {}}" class="textarea text-gray-800 dark:text-white"></textarea>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="form-control">
|
|
84
|
+
<label class="label">
|
|
85
|
+
<span class="label-text">Funds</span>
|
|
86
|
+
<span class="label-text">
|
|
87
|
+
<a class="btn btn-xs" @click="addFunds">+</a>
|
|
88
|
+
<a class="btn btn-xs" @click="removeFunds">-</a>
|
|
89
|
+
</span>
|
|
90
|
+
</label>
|
|
91
|
+
<label v-for="(coin, i) in funds" class="input-group" :key="i">
|
|
92
|
+
<input v-model="coin.amount" type="text" placeholder="0" class="input border w-full dark:text-white" />
|
|
93
|
+
<select v-model="coin.denom" class="select border dark:text-white">
|
|
94
|
+
<option v-for="b in balances" :value="b.denom">{{ b.denom.substring(0, 10) }}</option>
|
|
95
|
+
</select>
|
|
96
|
+
</label>
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
99
|
</template>
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
<script lang="ts" setup>
|
|
2
|
-
import { Coin } from '@cosmjs/amino';
|
|
3
|
-
import { PropType, computed, ref } from 'vue';
|
|
4
|
-
import { toBase64 } from '@cosmjs/encoding'
|
|
5
|
-
import { CoinMetadata } from '../../../utils/type';
|
|
6
|
-
|
|
7
|
-
const props = defineProps({
|
|
8
|
-
endpoint: { type: String, required: true },
|
|
9
|
-
sender: { type: String, required: true },
|
|
10
|
-
balances: Object as PropType<Coin[]>,
|
|
11
|
-
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
12
|
-
params: String,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
16
|
-
|
|
17
|
-
const admin = ref("")
|
|
18
|
-
const label = ref("")
|
|
19
|
-
const funds = ref([] as Coin[])
|
|
20
|
-
const msg = ref("")
|
|
21
|
-
|
|
22
|
-
const msgs = computed(() => {
|
|
23
|
-
return [{
|
|
24
|
-
typeUrl: '/cosmwasm.wasm.v1.MsgInstantiateContract',
|
|
25
|
-
value: {
|
|
26
|
-
/** Sender is the that actor that signed the messages */
|
|
27
|
-
sender: props.sender,
|
|
28
|
-
/** Admin is an optional address that can execute migrations */
|
|
29
|
-
admin: admin.value,
|
|
30
|
-
/** CodeID is the reference to the stored WASM code */
|
|
31
|
-
codeId: params.value.codeId,
|
|
32
|
-
/** Label is optional metadata to be stored with a contract instance. */
|
|
33
|
-
label: label.value,
|
|
34
|
-
/** Msg json encoded message to be passed to the contract on instantiation */
|
|
35
|
-
msg: toBase64(new TextEncoder().encode(msg.value)),
|
|
36
|
-
/** Funds coins that are transferred to the contract on instantiation */
|
|
37
|
-
funds: JSON.parse(JSON.stringify(funds.value)),
|
|
38
|
-
},
|
|
39
|
-
}]
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
function addFunds() {
|
|
43
|
-
const denom = props.balances?.at(0)?.denom || ""
|
|
44
|
-
funds.value.push({ amount: "", denom })
|
|
45
|
-
}
|
|
46
|
-
function removeFunds() {
|
|
47
|
-
if(funds.value.length > 0)
|
|
48
|
-
funds.value.pop()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const isValid = computed(() => {
|
|
52
|
-
let ok = true
|
|
53
|
-
let error = ""
|
|
54
|
-
if( Number(params.value.codeId) < 1) {
|
|
55
|
-
ok = false
|
|
56
|
-
error = "Code Id is not selected"
|
|
57
|
-
}
|
|
58
|
-
return { ok, error }
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
function initial() {
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
defineExpose({msgs, isValid, initial})
|
|
65
|
-
|
|
66
|
-
</script>
|
|
67
|
-
<template>
|
|
68
|
-
<div>
|
|
69
|
-
<div class="form-control">
|
|
70
|
-
<label class="label">
|
|
71
|
-
<span class="label-text">Sender</span>
|
|
72
|
-
</label>
|
|
73
|
-
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border
|
|
74
|
-
</div>
|
|
75
|
-
<div class="form-control">
|
|
76
|
-
<label class="label">
|
|
77
|
-
<span class="label-text">Admin</span>
|
|
78
|
-
</label>
|
|
79
|
-
<input v-model="admin" type="text" class="text-gray-600 dark:text-white input border
|
|
80
|
-
</div>
|
|
81
|
-
<div class="form-control">
|
|
82
|
-
<label class="label">
|
|
83
|
-
<span class="label-text">Label</span>
|
|
84
|
-
</label>
|
|
85
|
-
<input v-model="label" type="text" class="text-gray-600 dark:text-white input border
|
|
86
|
-
</div>
|
|
87
|
-
<div class="form-control">
|
|
88
|
-
<label class="label">
|
|
89
|
-
<span class="label-text">Messages</span>
|
|
90
|
-
</label>
|
|
91
|
-
<textarea v-model="msg" placeholder="{config: {}}" class="text-gray-600 dark:text-white textarea border
|
|
92
|
-
</div>
|
|
93
|
-
<div class="form-control">
|
|
94
|
-
<label class="label">
|
|
95
|
-
<span class="label-text">Funds</span>
|
|
96
|
-
<span class="label-text">
|
|
97
|
-
<a class="btn btn-xs" @click="addFunds">+</a>
|
|
98
|
-
<a class="btn btn-xs" @click="removeFunds">-</a>
|
|
99
|
-
</span>
|
|
100
|
-
</label>
|
|
101
|
-
<label v-for="(coin, i) in funds" class="input-group" :key="i">
|
|
102
|
-
<input v-model="coin.amount" type="text" placeholder="0" class="input border
|
|
103
|
-
<select v-model="coin.denom" class="select border
|
|
104
|
-
<option v-for="b in balances" :value="b.denom">{{ b.denom.substring(0, 10) }}</option>
|
|
105
|
-
</select>
|
|
106
|
-
</label>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { Coin } from '@cosmjs/amino';
|
|
3
|
+
import { PropType, computed, ref } from 'vue';
|
|
4
|
+
import { toBase64 } from '@cosmjs/encoding'
|
|
5
|
+
import { CoinMetadata } from '../../../utils/type';
|
|
6
|
+
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
endpoint: { type: String, required: true },
|
|
9
|
+
sender: { type: String, required: true },
|
|
10
|
+
balances: Object as PropType<Coin[]>,
|
|
11
|
+
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
12
|
+
params: String,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
16
|
+
|
|
17
|
+
const admin = ref("")
|
|
18
|
+
const label = ref("")
|
|
19
|
+
const funds = ref([] as Coin[])
|
|
20
|
+
const msg = ref("")
|
|
21
|
+
|
|
22
|
+
const msgs = computed(() => {
|
|
23
|
+
return [{
|
|
24
|
+
typeUrl: '/cosmwasm.wasm.v1.MsgInstantiateContract',
|
|
25
|
+
value: {
|
|
26
|
+
/** Sender is the that actor that signed the messages */
|
|
27
|
+
sender: props.sender,
|
|
28
|
+
/** Admin is an optional address that can execute migrations */
|
|
29
|
+
admin: admin.value,
|
|
30
|
+
/** CodeID is the reference to the stored WASM code */
|
|
31
|
+
codeId: params.value.codeId,
|
|
32
|
+
/** Label is optional metadata to be stored with a contract instance. */
|
|
33
|
+
label: label.value,
|
|
34
|
+
/** Msg json encoded message to be passed to the contract on instantiation */
|
|
35
|
+
msg: toBase64(new TextEncoder().encode(msg.value)),
|
|
36
|
+
/** Funds coins that are transferred to the contract on instantiation */
|
|
37
|
+
funds: JSON.parse(JSON.stringify(funds.value)),
|
|
38
|
+
},
|
|
39
|
+
}]
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function addFunds() {
|
|
43
|
+
const denom = props.balances?.at(0)?.denom || ""
|
|
44
|
+
funds.value.push({ amount: "", denom })
|
|
45
|
+
}
|
|
46
|
+
function removeFunds() {
|
|
47
|
+
if(funds.value.length > 0)
|
|
48
|
+
funds.value.pop()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isValid = computed(() => {
|
|
52
|
+
let ok = true
|
|
53
|
+
let error = ""
|
|
54
|
+
if( Number(params.value.codeId) < 1) {
|
|
55
|
+
ok = false
|
|
56
|
+
error = "Code Id is not selected"
|
|
57
|
+
}
|
|
58
|
+
return { ok, error }
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
function initial() {
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
defineExpose({msgs, isValid, initial})
|
|
65
|
+
|
|
66
|
+
</script>
|
|
67
|
+
<template>
|
|
68
|
+
<div>
|
|
69
|
+
<div class="form-control">
|
|
70
|
+
<label class="label">
|
|
71
|
+
<span class="label-text">Sender</span>
|
|
72
|
+
</label>
|
|
73
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border" />
|
|
74
|
+
</div>
|
|
75
|
+
<div class="form-control">
|
|
76
|
+
<label class="label">
|
|
77
|
+
<span class="label-text">Admin</span>
|
|
78
|
+
</label>
|
|
79
|
+
<input v-model="admin" type="text" class="text-gray-600 dark:text-white input border" />
|
|
80
|
+
</div>
|
|
81
|
+
<div class="form-control">
|
|
82
|
+
<label class="label">
|
|
83
|
+
<span class="label-text">Label</span>
|
|
84
|
+
</label>
|
|
85
|
+
<input v-model="label" type="text" class="text-gray-600 dark:text-white input border" />
|
|
86
|
+
</div>
|
|
87
|
+
<div class="form-control">
|
|
88
|
+
<label class="label">
|
|
89
|
+
<span class="label-text">Messages</span>
|
|
90
|
+
</label>
|
|
91
|
+
<textarea v-model="msg" placeholder="{config: {}}" class="text-gray-600 dark:text-white textarea border"></textarea>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="form-control">
|
|
94
|
+
<label class="label">
|
|
95
|
+
<span class="label-text">Funds</span>
|
|
96
|
+
<span class="label-text">
|
|
97
|
+
<a class="btn btn-xs" @click="addFunds">+</a>
|
|
98
|
+
<a class="btn btn-xs" @click="removeFunds">-</a>
|
|
99
|
+
</span>
|
|
100
|
+
</label>
|
|
101
|
+
<label v-for="(coin, i) in funds" class="input-group" :key="i">
|
|
102
|
+
<input v-model="coin.amount" type="text" placeholder="0" class="input border w-full dark:text-white" />
|
|
103
|
+
<select v-model="coin.denom" class="select border dark:text-white">
|
|
104
|
+
<option v-for="b in balances" :value="b.denom">{{ b.denom.substring(0, 10) }}</option>
|
|
105
|
+
</select>
|
|
106
|
+
</label>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
109
|
</template>
|