@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.
- 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-465ae991.js} +151 -149
- package/dist/ping-widget.js +2 -2
- package/dist/ping-widget.umd.cjs +17 -17
- package/dist/{query.lcd-3d4d3495.js → query.lcd-d9c6163c.js} +1 -1
- package/dist/{query.rpc.Query-b7807c29.js → query.rpc.Query-a479e6f9.js} +1 -1
- package/dist/{tx.rpc.msg-59c3408a.js → tx.rpc.msg-7444045d.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 +8 -8
- 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 +132 -7
- package/lib/main.ts +23 -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 +3 -3
- package/postcss.config.js +6 -6
- package/src/App.vue +225 -225
- package/src/main.ts +7 -4
- package/src/styles/design-system.css +150 -0
- package/src/vite-env.d.ts +1 -1
- package/tailwind.config.js +211 -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,104 +1,104 @@
|
|
|
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
|
-
|
|
7
|
-
const props = defineProps({
|
|
8
|
-
endpoint: {type: String, required: true },
|
|
9
|
-
sender: {type: String, required: true},
|
|
10
|
-
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
11
|
-
params: String,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
15
|
-
const delegation = ref({} as {balance: Coin, delegation: {delegator_address: string, shares: string, validator_address: string}})
|
|
16
|
-
const amount = ref("")
|
|
17
|
-
const amountDenom = ref("")
|
|
18
|
-
const error = ref("")
|
|
19
|
-
|
|
20
|
-
const msgs = computed(() => {
|
|
21
|
-
const convert = new TokenUnitConverter(props.metadata)
|
|
22
|
-
return [{
|
|
23
|
-
typeUrl: '/cosmos.staking.v1beta1.MsgUndelegate',
|
|
24
|
-
value: {
|
|
25
|
-
delegatorAddress: props.sender,
|
|
26
|
-
validatorAddress: params.value.validator_address,
|
|
27
|
-
amount: convert.displayToBase(delegation.value.balance?.denom, {
|
|
28
|
-
amount: String(amount.value),
|
|
29
|
-
denom: amountDenom.value,
|
|
30
|
-
}),
|
|
31
|
-
},
|
|
32
|
-
}]
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
const units = computed(() => {
|
|
36
|
-
const denom = delegation.value.balance?.denom
|
|
37
|
-
if(!props.metadata || !props.metadata[denom]) {
|
|
38
|
-
amountDenom.value = denom
|
|
39
|
-
return [{denom: denom, exponent: 0, aliases: []}]
|
|
40
|
-
}
|
|
41
|
-
const list = props.metadata[denom].denom_units.sort((a, b) => b.exponent - a.exponent)
|
|
42
|
-
if(list.length > 0) amountDenom.value = list[0].denom
|
|
43
|
-
return list
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
const isValid = computed(() => {
|
|
47
|
-
let ok = true
|
|
48
|
-
let error = ""
|
|
49
|
-
if(!props.sender) {
|
|
50
|
-
ok = false
|
|
51
|
-
error = "Sender is empty"
|
|
52
|
-
}
|
|
53
|
-
if(!params.value.validator_address) {
|
|
54
|
-
ok = false
|
|
55
|
-
error = "Validator is empty"
|
|
56
|
-
}
|
|
57
|
-
if(!(Number(amount.value) > 0)) {
|
|
58
|
-
ok = false
|
|
59
|
-
error = "Amount should be great than 0"
|
|
60
|
-
}
|
|
61
|
-
return { ok, error }
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
function initial() {
|
|
65
|
-
getDelegations(props.endpoint, params.value.validator_address, props.sender).then(x => {
|
|
66
|
-
delegation.value = x.delegation_response
|
|
67
|
-
}).catch(err => {
|
|
68
|
-
error.value = err
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const available = computed(() => {
|
|
73
|
-
const convert = new TokenUnitConverter(props.metadata);
|
|
74
|
-
const base = delegation.value?.balance || {amount: "", denom: ""}
|
|
75
|
-
return {
|
|
76
|
-
base,
|
|
77
|
-
display: convert.baseToUnit(base, amountDenom.value),
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
defineExpose({msgs, isValid, initial})
|
|
82
|
-
</script>
|
|
83
|
-
<template>
|
|
84
|
-
<div>
|
|
85
|
-
<div class="form-control">
|
|
86
|
-
<label class="label">
|
|
87
|
-
<span class="label-text">Sender</span>
|
|
88
|
-
</label>
|
|
89
|
-
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-
|
|
90
|
-
</div>
|
|
91
|
-
<div class="form-control">
|
|
92
|
-
<label class="label">
|
|
93
|
-
<span class="label-text">Amount</span>
|
|
94
|
-
</label>
|
|
95
|
-
<label class="input-group">
|
|
96
|
-
<input v-model="amount" type="number" :placeholder="`Avaiable: ${available.display?.amount}`" class="input border border-gray-300 dark:border-
|
|
97
|
-
<select v-model="amountDenom" class="select select-bordered dark:border-
|
|
98
|
-
<option v-for="u in units">{{ u.denom }}</option>
|
|
99
|
-
</select>
|
|
100
|
-
</label>
|
|
101
|
-
</div>
|
|
102
|
-
<div class="text-error">{{ error }}</div>
|
|
103
|
-
</div>
|
|
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
|
+
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
endpoint: {type: String, required: true },
|
|
9
|
+
sender: {type: String, required: true},
|
|
10
|
+
metadata: Object as PropType<Record<string, CoinMetadata>>,
|
|
11
|
+
params: String,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const params = computed(() => JSON.parse(props.params || "{}"))
|
|
15
|
+
const delegation = ref({} as {balance: Coin, delegation: {delegator_address: string, shares: string, validator_address: string}})
|
|
16
|
+
const amount = ref("")
|
|
17
|
+
const amountDenom = ref("")
|
|
18
|
+
const error = ref("")
|
|
19
|
+
|
|
20
|
+
const msgs = computed(() => {
|
|
21
|
+
const convert = new TokenUnitConverter(props.metadata)
|
|
22
|
+
return [{
|
|
23
|
+
typeUrl: '/cosmos.staking.v1beta1.MsgUndelegate',
|
|
24
|
+
value: {
|
|
25
|
+
delegatorAddress: props.sender,
|
|
26
|
+
validatorAddress: params.value.validator_address,
|
|
27
|
+
amount: convert.displayToBase(delegation.value.balance?.denom, {
|
|
28
|
+
amount: String(amount.value),
|
|
29
|
+
denom: amountDenom.value,
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
}]
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const units = computed(() => {
|
|
36
|
+
const denom = delegation.value.balance?.denom
|
|
37
|
+
if(!props.metadata || !props.metadata[denom]) {
|
|
38
|
+
amountDenom.value = denom
|
|
39
|
+
return [{denom: denom, exponent: 0, aliases: []}]
|
|
40
|
+
}
|
|
41
|
+
const list = props.metadata[denom].denom_units.sort((a, b) => b.exponent - a.exponent)
|
|
42
|
+
if(list.length > 0) amountDenom.value = list[0].denom
|
|
43
|
+
return list
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const isValid = computed(() => {
|
|
47
|
+
let ok = true
|
|
48
|
+
let error = ""
|
|
49
|
+
if(!props.sender) {
|
|
50
|
+
ok = false
|
|
51
|
+
error = "Sender is empty"
|
|
52
|
+
}
|
|
53
|
+
if(!params.value.validator_address) {
|
|
54
|
+
ok = false
|
|
55
|
+
error = "Validator is empty"
|
|
56
|
+
}
|
|
57
|
+
if(!(Number(amount.value) > 0)) {
|
|
58
|
+
ok = false
|
|
59
|
+
error = "Amount should be great than 0"
|
|
60
|
+
}
|
|
61
|
+
return { ok, error }
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
function initial() {
|
|
65
|
+
getDelegations(props.endpoint, params.value.validator_address, props.sender).then(x => {
|
|
66
|
+
delegation.value = x.delegation_response
|
|
67
|
+
}).catch(err => {
|
|
68
|
+
error.value = err
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const available = computed(() => {
|
|
73
|
+
const convert = new TokenUnitConverter(props.metadata);
|
|
74
|
+
const base = delegation.value?.balance || {amount: "", denom: ""}
|
|
75
|
+
return {
|
|
76
|
+
base,
|
|
77
|
+
display: convert.baseToUnit(base, amountDenom.value),
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
defineExpose({msgs, isValid, initial})
|
|
82
|
+
</script>
|
|
83
|
+
<template>
|
|
84
|
+
<div>
|
|
85
|
+
<div class="form-control">
|
|
86
|
+
<label class="label">
|
|
87
|
+
<span class="label-text">Sender</span>
|
|
88
|
+
</label>
|
|
89
|
+
<input :value="sender" type="text" class="text-gray-600 dark:text-white input border !border-gray-300 dark:!border-neutral-700" />
|
|
90
|
+
</div>
|
|
91
|
+
<div class="form-control">
|
|
92
|
+
<label class="label">
|
|
93
|
+
<span class="label-text">Amount</span>
|
|
94
|
+
</label>
|
|
95
|
+
<label class="input-group">
|
|
96
|
+
<input v-model="amount" type="number" :placeholder="`Avaiable: ${available.display?.amount}`" class="input border border-gray-300 dark:border-neutral-700 w-full dark:text-white" />
|
|
97
|
+
<select v-model="amountDenom" class="select select-bordered dark:border-neutral-700 dark:text-white">
|
|
98
|
+
<option v-for="u in units">{{ u.denom }}</option>
|
|
99
|
+
</select>
|
|
100
|
+
</label>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="text-error">{{ error }}</div>
|
|
103
|
+
</div>
|
|
104
104
|
</template>
|
|
@@ -1,63 +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-
|
|
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>
|
|
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-neutral-700" />
|
|
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
63
|
</template>
|
|
@@ -1,56 +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-
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
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-neutral-700" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
56
|
</template>
|
|
@@ -1,75 +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-
|
|
73
|
-
</div>
|
|
74
|
-
</div>
|
|
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-neutral-700" />
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
75
|
</template>
|