@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
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { PropType, computed, onMounted, ref } from 'vue';
|
|
3
|
+
import { getDelegations } from '../../../utils/http'
|
|
4
|
+
import { Coin, CoinMetadata } from '../../../utils/type';
|
|
5
|
+
import { TokenUnitConverter } from '../../../utils/TokenUnitConverter';
|
|
6
|
+
import { MsgUndelegate } from "@initia/initia.proto/initia/mstaking/v1/tx"
|
|
7
|
+
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
endpoint: {type: String, required: true },
|
|
10
|
+
sender: {type: String, required: true},
|
|
11
|
+
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
12
|
+
params: String,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
16
|
+
const delegation = ref({} as {balance: Coin, delegation: {delegator_address: string, shares: string, validator_address: string}})
|
|
17
|
+
const amount = ref("")
|
|
18
|
+
const amountDenom = ref("")
|
|
19
|
+
const error = ref("")
|
|
20
|
+
|
|
21
|
+
function isInitiaChain(endpoint: string): boolean {
|
|
22
|
+
return props.endpoint.indexOf("init") !== -1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const msgs = computed(() => {
|
|
26
|
+
const convert = new TokenUnitConverter(props.metadata);
|
|
27
|
+
const baseAmount = convert.displayToBase(delegation.value.balance?.denom, {
|
|
28
|
+
amount: String(amount.value),
|
|
29
|
+
denom: amountDenom.value,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (isInitiaChain(props.endpoint)) {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
typeUrl: '/initia.mstaking.v1.MsgUndelegate',
|
|
36
|
+
value: MsgUndelegate.fromPartial({
|
|
37
|
+
delegatorAddress: props.sender,
|
|
38
|
+
validatorAddress: params.value.validator_address,
|
|
39
|
+
amount: [baseAmount],
|
|
40
|
+
}),
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
} else {
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
typeUrl: '/cosmos.staking.v1beta1.MsgUndelegate',
|
|
47
|
+
value: {
|
|
48
|
+
delegatorAddress: props.sender,
|
|
49
|
+
validatorAddress: params.value.validator_address,
|
|
50
|
+
amount: baseAmount,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const units = computed(() => {
|
|
58
|
+
const denom = delegation.value.balance?.denom
|
|
59
|
+
if(!props.metadata || !props.metadata[denom]) {
|
|
60
|
+
amountDenom.value = denom
|
|
61
|
+
return [{denom: denom, exponent: 0, aliases: []}]
|
|
62
|
+
}
|
|
63
|
+
const list = props.metadata[denom].denom_units.sort((a, b) => b.exponent - a.exponent)
|
|
64
|
+
if(list.length > 0) amountDenom.value = list[0].denom
|
|
65
|
+
return list
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const isValid = computed(() => {
|
|
69
|
+
let ok = true
|
|
70
|
+
let error = ""
|
|
71
|
+
if(!props.sender) {
|
|
72
|
+
ok = false
|
|
73
|
+
error = "Sender is empty"
|
|
74
|
+
}
|
|
75
|
+
if(!params.value.validator_address) {
|
|
76
|
+
ok = false
|
|
77
|
+
error = "Validator is empty"
|
|
78
|
+
}
|
|
79
|
+
if(!(Number(amount.value) > 0)) {
|
|
80
|
+
ok = false
|
|
81
|
+
error = "Amount should be great than 0"
|
|
82
|
+
}
|
|
83
|
+
return { ok, error }
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
function initial() {
|
|
87
|
+
getDelegations(props.endpoint, params.value.validator_address, props.sender).then(x => {
|
|
88
|
+
const balance = x.delegation_response.balance;
|
|
89
|
+
if (isInitiaChain(props.endpoint)) {
|
|
90
|
+
delegation.value = {
|
|
91
|
+
balance: Array.isArray(balance) ? balance.find(b => b.denom === 'uinit') || { amount: "0", denom: "uinit" } : balance,
|
|
92
|
+
delegation: { delegator_address: props.sender, shares: "", validator_address: params.value.validator_address }
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
delegation.value = {
|
|
96
|
+
balance: Array.isArray(balance) ? balance[0] || { amount: "0", denom: amountDenom.value } : balance,
|
|
97
|
+
delegation: { delegator_address: props.sender, shares: "", validator_address: params.value.validator_address }
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}).catch(err => {
|
|
101
|
+
error.value = err
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const available = computed(() => {
|
|
106
|
+
const convert = new TokenUnitConverter(props.metadata);
|
|
107
|
+
const base = delegation.value?.balance || {amount: "", denom: ""}
|
|
108
|
+
return {
|
|
109
|
+
base,
|
|
110
|
+
display: convert.baseToUnit(base, amountDenom.value),
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
defineExpose({msgs, isValid, initial})
|
|
115
|
+
</script>
|
|
116
|
+
<template>
|
|
117
|
+
<div>
|
|
118
|
+
<div class="form-control">
|
|
119
|
+
<label class="label">
|
|
120
|
+
<span class="label-text">Sender</span>
|
|
121
|
+
</label>
|
|
122
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" />
|
|
123
|
+
</div>
|
|
124
|
+
<div class="form-control">
|
|
125
|
+
<label class="label">
|
|
126
|
+
<span class="label-text">Amount</span>
|
|
127
|
+
</label>
|
|
128
|
+
<label class="input-group">
|
|
129
|
+
<input v-model="amount" type="number" :placeholder="`Avaiable: ${available.display?.amount}`" class="input border border-gray-300 dark:border-gray-600 w-full dark:text-white" />
|
|
130
|
+
<select v-model="amountDenom" class="select select-bordered dark:text-white">
|
|
131
|
+
<option v-for="u in units">{{ u.denom }}</option>
|
|
132
|
+
</select>
|
|
133
|
+
</label>
|
|
134
|
+
</div>
|
|
135
|
+
<div class="text-error">{{ error }}</div>
|
|
136
|
+
</div>
|
|
137
|
+
</template>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { PropType, computed, ref } from 'vue';
|
|
3
|
+
import { CoinMetadata } from '../../../utils/type';
|
|
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
|
+
const option = ref("1")
|
|
13
|
+
|
|
14
|
+
const msgs = computed(() => {
|
|
15
|
+
return [{
|
|
16
|
+
typeUrl: '/cosmos.gov.v1beta1.MsgVote',
|
|
17
|
+
value: {
|
|
18
|
+
voter: props.sender,
|
|
19
|
+
proposalId: params.value.proposal_id,
|
|
20
|
+
option: Number(option.value),
|
|
21
|
+
},
|
|
22
|
+
}]
|
|
23
|
+
})
|
|
24
|
+
const isValid = computed(() => {
|
|
25
|
+
let ok = true
|
|
26
|
+
let error = ""
|
|
27
|
+
if(!params.value.proposal_id) {
|
|
28
|
+
ok = false
|
|
29
|
+
error = "Proposal id is empty"
|
|
30
|
+
}
|
|
31
|
+
if(!option.value) {
|
|
32
|
+
ok = false
|
|
33
|
+
error = "Vote is empty"
|
|
34
|
+
}
|
|
35
|
+
return { ok, error }
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
function initial() {
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
defineExpose({msgs, isValid, initial})
|
|
42
|
+
</script>
|
|
43
|
+
<template>
|
|
44
|
+
<div>
|
|
45
|
+
<div class="form-control">
|
|
46
|
+
<label class="label">
|
|
47
|
+
<span class="label-text">Sender</span>
|
|
48
|
+
</label>
|
|
49
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" />
|
|
50
|
+
</div>
|
|
51
|
+
<div class="form-control">
|
|
52
|
+
<label class="label">
|
|
53
|
+
<span class="label-text">Option</span>
|
|
54
|
+
</label>
|
|
55
|
+
<div class="flex">
|
|
56
|
+
<input v-model="option" type="radio" id="yes" value="1" class="radio radio-success mx-2"/><label for="yes"> Yes</label>
|
|
57
|
+
<input v-model="option" type="radio" id="no" value="3" class="radio radio-error mx-2" /><label for="no"> No</label>
|
|
58
|
+
<input v-model="option" type="radio" id="veto" value="4" class="radio radio-error mx-2" /><label for="veto"> No With Veto</label>
|
|
59
|
+
<input v-model="option" type="radio" id="abstain" value="2" class="radio radio-dark mx-2" /><label for="abstain"> Abstain</label>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, onMounted, ref } from 'vue';
|
|
3
|
+
import { getDelegateRewards } from '../../../utils/http'
|
|
4
|
+
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
endpoint: { type: String, required: true },
|
|
7
|
+
sender: { type: String, required: true },
|
|
8
|
+
params: String,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const rewards = ref([] as { reward: { amount: string, denom: string }, validator_address: string }[])
|
|
12
|
+
|
|
13
|
+
const msgs = computed(() => {
|
|
14
|
+
return rewards.value.map(x => {
|
|
15
|
+
return {
|
|
16
|
+
typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward',
|
|
17
|
+
value: {
|
|
18
|
+
delegatorAddress: props.sender,
|
|
19
|
+
validatorAddress: x.validator_address,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
const isValid = computed(() => {
|
|
26
|
+
let ok = true
|
|
27
|
+
let error = ""
|
|
28
|
+
if (!props.sender) {
|
|
29
|
+
ok = false
|
|
30
|
+
error = "Sender is empty"
|
|
31
|
+
}
|
|
32
|
+
if (rewards.value.length === 0) {
|
|
33
|
+
ok = false
|
|
34
|
+
error = "No delegation found"
|
|
35
|
+
}
|
|
36
|
+
return { ok, error }
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
function initial() {
|
|
40
|
+
getDelegateRewards(props.endpoint, props.sender).then(x => {
|
|
41
|
+
rewards.value = x.rewards
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
defineExpose({ msgs, isValid, initial })
|
|
46
|
+
</script>
|
|
47
|
+
<template>
|
|
48
|
+
<div>
|
|
49
|
+
<div class="form-control">
|
|
50
|
+
<label class="label">
|
|
51
|
+
<span class="label-text">Sender</span>
|
|
52
|
+
</label>
|
|
53
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
import { getDelegateRewards } from '../../../utils/http';
|
|
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
|
+
const rewards = ref([] as { reward: { amount: string, denom: string }, validator_address: string }[])
|
|
13
|
+
|
|
14
|
+
const msgs = computed(() => {
|
|
15
|
+
const delegations = rewards.value?.map(x => {
|
|
16
|
+
return {
|
|
17
|
+
typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward',
|
|
18
|
+
value: {
|
|
19
|
+
delegatorAddress: props.sender,
|
|
20
|
+
validatorAddress: x.validator_address,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
return [
|
|
25
|
+
...delegations,
|
|
26
|
+
{
|
|
27
|
+
typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission',
|
|
28
|
+
value: {
|
|
29
|
+
validatorAddress: params.value.validator_address,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const isValid = computed(() => {
|
|
36
|
+
let ok = true
|
|
37
|
+
let error = ""
|
|
38
|
+
if (!props.sender) {
|
|
39
|
+
ok = false
|
|
40
|
+
error = "Sender is empty"
|
|
41
|
+
}
|
|
42
|
+
if (!params.value.validator_address) {
|
|
43
|
+
ok = false
|
|
44
|
+
error = "Validator is empty"
|
|
45
|
+
}
|
|
46
|
+
if (!rewards.value || rewards.value.length < 0) {
|
|
47
|
+
ok = false
|
|
48
|
+
error = "No delegation found"
|
|
49
|
+
}
|
|
50
|
+
if (rewards.value.findIndex(x => x.validator_address === params.value.validator_address) === -1) {
|
|
51
|
+
ok = false
|
|
52
|
+
error = "You are not the validator!"
|
|
53
|
+
}
|
|
54
|
+
return { ok, error }
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
function initial() {
|
|
59
|
+
getDelegateRewards(props.endpoint, props.sender).then(x => {
|
|
60
|
+
rewards.value = x.rewards
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
defineExpose({ msgs, isValid, initial })
|
|
65
|
+
</script>
|
|
66
|
+
<template>
|
|
67
|
+
<div>
|
|
68
|
+
<div class="form-control">
|
|
69
|
+
<label class="label">
|
|
70
|
+
<span class="label-text">Sender</span>
|
|
71
|
+
</label>
|
|
72
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" />
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
</template>
|
|
@@ -0,0 +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 !border-gray-300 dark:!border-gray-600" />
|
|
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 !border-gray-300 dark:!border-gray-600" :value="params.contract" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
</template>
|
|
@@ -0,0 +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 !border-gray-300 dark:!border-gray-600" />
|
|
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 !border-gray-300 dark:!border-gray-600" />
|
|
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 !border-gray-300 dark:!border-gray-600"></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 border-gray-300 dark:border-gray-600 w-full dark:text-white" />
|
|
93
|
+
<select v-model="coin.denom" class="select border border-gray-300 dark:border-gray-600 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
|
+
</template>
|
|
@@ -0,0 +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 !border-gray-300 dark:!border-gray-600" />
|
|
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 !border-gray-300 dark:!border-gray-600" />
|
|
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 !border-gray-300 dark:!border-gray-600" />
|
|
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 !border-gray-300 dark:!border-gray-600"></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 border-gray-300 dark:border-gray-600 w-full dark:text-white" />
|
|
103
|
+
<select v-model="coin.denom" class="select border border-gray-300 dark:border-gray-600 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
|
+
</template>
|
|
@@ -0,0 +1,77 @@
|
|
|
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 codeId = ref("")
|
|
14
|
+
const msg = ref("{}")
|
|
15
|
+
|
|
16
|
+
const msgs = computed(() => {
|
|
17
|
+
return [{
|
|
18
|
+
typeUrl: '/cosmwasm.wasm.v1.MsgMigrateContract',
|
|
19
|
+
value: {
|
|
20
|
+
/** Sender is the that actor that signed the messages */
|
|
21
|
+
sender: props.sender,
|
|
22
|
+
/** contract address that can execute migrations */
|
|
23
|
+
contract: params.value.contract,
|
|
24
|
+
/** CodeID is the reference to the stored WASM code */
|
|
25
|
+
codeId: codeId.value,
|
|
26
|
+
/** Msg json encoded message to be passed to the contract on instantiation */
|
|
27
|
+
msg: toBase64(new TextEncoder().encode(msg.value)),
|
|
28
|
+
},
|
|
29
|
+
}]
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const isValid = computed(() => {
|
|
33
|
+
let ok = true
|
|
34
|
+
let error = ""
|
|
35
|
+
if( Number(codeId.value) < 1) {
|
|
36
|
+
ok = false
|
|
37
|
+
error = "Code Id is not selected"
|
|
38
|
+
}
|
|
39
|
+
return { ok, error }
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function initial() {
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
defineExpose({msgs, isValid, initial})
|
|
46
|
+
|
|
47
|
+
</script>
|
|
48
|
+
<template>
|
|
49
|
+
<div>
|
|
50
|
+
<div class="form-control">
|
|
51
|
+
<label class="label">
|
|
52
|
+
<span class="label-text">Sender</span>
|
|
53
|
+
</label>
|
|
54
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" />
|
|
55
|
+
</div>
|
|
56
|
+
<div class="form-control">
|
|
57
|
+
<label class="label">
|
|
58
|
+
<span class="label-text">Contract Address</span>
|
|
59
|
+
</label>
|
|
60
|
+
<input type="text" readonly class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" :value="params.contract" />
|
|
61
|
+
</div>
|
|
62
|
+
|
|
63
|
+
<div class="form-control">
|
|
64
|
+
<label class="label">
|
|
65
|
+
<span class="label-text">Code Id</span>
|
|
66
|
+
</label>
|
|
67
|
+
<input v-model="codeId" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-gray-600" />
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="form-control">
|
|
71
|
+
<label class="label">
|
|
72
|
+
<span class="label-text">Messages</span>
|
|
73
|
+
</label>
|
|
74
|
+
<textarea v-model="msg" placeholder="{config: {}}" class="text-gray-600 dark:text-white textarea border !border-gray-300 dark:!border-gray-600"></textarea>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</template>
|