Skip to content

Commit

Permalink
Merge branch 'suite' into dac-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
mo-c4t authored Nov 28, 2024
2 parents 6724ec7 + c3b02c3 commit 6c0cad2
Show file tree
Hide file tree
Showing 15 changed files with 1,400 additions and 963 deletions.
2 changes: 1 addition & 1 deletion caminojs
Submodule caminojs updated 284 files
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@
"vue": "^2.6.11",
"vue-cli-plugin-vuetify": "^2.0.3",
"vuetify": "^2.6.14",
"vuetify-loader": "^1.9.2"
"vuetify-loader": "^1.9.2",
"xss": "1.0.14"
}
}
10 changes: 8 additions & 2 deletions src/components/wallet/earn/CreateOfferForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,8 @@ export default class CreateOfferForm extends Vue {
/* methods */
async submitCreateOffer() {
if (!this.isRestricted) this.offer.ownerAddress = undefined
if (!this.isRestricted || this.wallet.type === 'multisig')
this.offer.ownerAddress = undefined
else this.offer.ownerAddress = this.wallet?.getStaticAddress('P')
this.txState = TxState.started
const wallet: WalletType = this.$store.state.activeWallet
Expand All @@ -793,7 +794,12 @@ export default class CreateOfferForm extends Vue {
try {
const result = await WalletHelper.buildAddDepositOfferTx(wallet, offer)
this.txState = TxState.waiting
this.waitTxConfirm(result, addresses, this.offer.start.toNumber(), this.isRestricted)
this.waitTxConfirm(
result,
addresses,
this.offer.start.toNumber(),
this.wallet.type === 'multisig' ? false : this.isRestricted
)
} catch (error) {
if (error instanceof SignatureError) {
await this.$store.dispatch('Signavault/updateTransaction')
Expand Down
1 change: 1 addition & 0 deletions src/components/wallet/portfolio/Fungibles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export default class Fungibles extends Vue {
.headers,
.asset {
width: 100%;
display: grid;
grid-template-columns: max-content 1fr 100px 1fr;
}
Expand Down
40 changes: 34 additions & 6 deletions src/components/wallet/studio/mint/MintForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,21 @@
</div>
<div>
<label>{{ $t('studio.mint.form_col.label1') }}</label>
<CamInput type="number" min="1" v-model="quantity" style="width: 100%" />
<CamInput
type="number"
:min="minQuantity"
v-model="quantity"
style="width: 100%"
/>
</div>
<div>
<label>{{ $t('studio.mint.form_col.label2') }}</label>
<input
type="text"
:value="addresses.join(',')"
@input="onAddressInput"
style="width: 100%"
/>
</div>
<div class="fee">
<p>
Expand Down Expand Up @@ -201,10 +215,10 @@ export default class MintNft extends Vue {
@Prop() mintUtxo!: UTXO
quantity = 1
addresses = []
nftType: NftType = 'url'
nftFormType = 'generic'
payloadPreview: null | PayloadBase = null
canSubmit = false
isSuccess = false
isLoading = false
txId = ''
Expand Down Expand Up @@ -282,10 +296,21 @@ export default class MintNft extends Vue {
return bnToBig(ava.XChain().getTxFee(), 9)
}
get canSubmit(): boolean {
return this.payloadPreview !== null && this.quantity >= this.minQuantity
}
get minQuantity(): number {
return this.addresses.length || 1
}
onAddressInput(ev: any) {
this.addresses = ev.target.value.trim().split(',')
}
onInput(form: NftMintFormType | null) {
if (form === null) {
this.payloadPreview = null
this.canSubmit = false
return
}
Expand Down Expand Up @@ -313,7 +338,6 @@ export default class MintNft extends Vue {
}
this.payloadPreview = payload
this.canSubmit = true
} catch (e) {
console.error(e)
}
Expand Down Expand Up @@ -355,9 +379,13 @@ export default class MintNft extends Vue {
if (!wallet) return
this.isLoading = true
try {
let txId = await wallet.mintNft(this.mintUtxo, this.payloadPreview, this.quantity)
let txId = await wallet.mintNft(
this.mintUtxo,
this.payloadPreview,
this.quantity,
this.addresses
)
this.onSuccess(txId)
} catch (e) {
console.error(e)
Expand Down
231 changes: 231 additions & 0 deletions src/components/wallet/transfer/BulkTransfer.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<template>
<div class="bulk_card">
<div>
<label>{{ $t('transfer.receivers') }}</label>
<input
type="text"
v-model="orderString"
class="hover_border"
placeholder="X-[...];1.5,X-[...];10"
/>
<span class="bulk_info bulk_error" v-if="error !== ''">Error: {{ error }}</span>
<span class="bulk_info" v-else>
Addresses: {{ orders.length }}, Amount: {{ totalBig.toLocaleString() }}
{{ asset.symbol }}
</span>
</div>
<div class="checkout">
<p>
<label>{{ $t('transfer.memo').toString() }}</label>
<textarea class="memo" maxlength="256" placeholder="Memo" v-model="memo"></textarea>
</p>
<v-btn
id="submit"
depressed
class="button_primary"
:loading="processing"
:ripple="false"
@click="submit"
:disabled="!canSend"
block
>
{{ $t('transfer.send') }}
</v-btn>
</div>
</div>
</template>

<script lang="ts">
import { Component, Vue, Watch } from 'vue-property-decorator'
import { ava, bintools } from '@/AVA'
// import { ava, bintools } from '@/AVA'
import { BulkOrder } from './types'
import { Big } from '@/helpers/helper'
import { WalletHelper } from '@/helpers/wallet_helper'
import AvaAsset from '@/js/AvaAsset'
import { WalletType } from '@/js/wallets/types'
import { BN, Buffer } from '@c4tplatform/caminojs/dist'
import { SignatureError } from '@c4tplatform/caminojs/dist/common'
import { TxState } from '../earn/ChainTransfer/types'
@Component
export default class BulkTransfer extends Vue {
orderString: string = ''
memo: string = ''
orders: BulkOrder[] = []
totalBig: Big = Big(0)
error: string = ''
txState: TxState = TxState.waiting
@Watch('orderString')
onUpdateOrderString(o: string, n: string) {
const pairs = this.orderString.trim().split(',') as string[]
const denom = this.asset.denomination
const orders: BulkOrder[] = []
var totalBig = Big(0)
const hrp = ava.getHRP()
try {
pairs.forEach((p, index) => {
const parts = p.split(';')
if (parts.length === 2) {
const addr = bintools.parseAddress(parts[0], 'X', hrp)
if (!addr) throw new Error(`Pair ${index}: Invalid Address`)
try {
const big = Big(parts[1])
orders.push({
address: parts[0],
amount: new BN(big.mul(Math.pow(10, denom)).toString()),
})
totalBig = totalBig.add(big)
} catch (e: unknown) {
throw new Error(`Pair ${index}: Cannot parse amount`)
}
}
})
} catch (e: any) {
this.error = e.message
this.orders = []
this.totalBig = Big(0)
return
}
this.orders = orders
this.totalBig = totalBig
this.error = ''
}
get asset(): AvaAsset {
return this.$store.getters['Assets/AssetAVA']
}
get processing(): boolean {
return this.txState === TxState.started
}
get canSend(): boolean {
return this.txState !== TxState.started && this.orders.length > 0
}
async submit() {
const wallet: WalletType = this.$store.state.activeWallet
try {
this.txState = TxState.started
const txId = await WalletHelper.issueBulkTx(
wallet,
this.asset,
this.orders,
Buffer.from(this.memo)
)
this.waitTxConfirm(txId)
} catch (error) {
if (error instanceof SignatureError) {
this.txState = TxState.success
this.orderString = ''
this.$store.dispatch('updateTransaction', {
onlyMultisig: true,
msgType: 'success',
msgTitle: 'Airdrop Transaction',
msgText: 'Transaction Recorded.',
})
} else {
this.txState = TxState.failed
console.error(error)
this.$store.dispatch('Notifications/add', {
type: 'error',
title: 'Airdrop Failed',
message: error,
})
return
}
}
}
async waitTxConfirm(txId: string) {
const status = await ava.XChain().getTxStatus(txId)
if (status === 'Unknown' || status === 'Processing') {
// if not confirmed ask again
setTimeout(() => {
this.waitTxConfirm(txId)
}, 500)
return false
} else if (status === 'Dropped') {
// If dropped stop the process
this.txState = TxState.failed
return false
} else {
// If success display success page
this.txState = TxState.success
this.orderString = ''
this.$store.dispatch('updateTransaction', {
withDeposit: true,
msgType: 'success',
msgTitle: 'Airdrop Transaction',
msgText: `Success (TX: ${txId})`,
})
}
}
}
</script>

<style scoped lang="scss">
@use '../../../styles/abstracts/mixins';
.bulk_card {
label {
margin-top: 6px;
color: var(--primary-color);
font-size: 14px;
margin-bottom: 3px;
}
input {
background-color: var(--bg-light);
padding: 8px 12px;
display: block;
font-size: 14px;
color: var(--primary-color);
margin-top: 10px;
width: 100%;
}
.bulk_info {
font-size: small;
color: var(--primary-color-light);
}
.bulk_error {
color: var(--error);
}
.checkout {
display: grid;
margin-top: 16px;
grid-template-columns: auto 200px;
gap: 16px;
align-items: end;
}
.memo {
display: block;
font-size: 14px;
background-color: var(--bg-light);
resize: none;
width: 100%;
height: 52px;
border-radius: var(--border-radius-sm);
padding: 4px 12px;
margin-top: 10px;
}
@include mixins.mobile-device {
.checkout {
grid-template-columns: auto;
}
}
}
</style>
Loading

0 comments on commit 6c0cad2

Please sign in to comment.