Skip to content

Commit

Permalink
🐛 Fix total arweave fee was sent as per file
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Feb 21, 2024
1 parent b3d7af8 commit 5207e88
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion components/IscnUploadForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ export default class IscnUploadForm extends Vue {
uploadStatus: UploadStatus = '';
arweaveFeeTargetAddress: string = ''
arweaveFee = new BigNumber(0)
arweaveFeeMap: Record<string, string> = {}
sentArweaveTransactionInfo = new Map<
string, { transactionHash?: string, arweaveId?: string }
>()
Expand Down Expand Up @@ -632,6 +633,7 @@ export default class IscnUploadForm extends Vue {
const { address, arweaveId, LIKE, ipfsHash } = result;
if (LIKE) {
totalFee = totalFee.plus(new BigNumber(LIKE));
this.arweaveFeeMap[ipfsHash] = LIKE;
}
if (arweaveId) {
this.sentArweaveTransactionInfo.set(ipfsHash, { transactionHash: '', arweaveId });
Expand Down Expand Up @@ -666,10 +668,11 @@ export default class IscnUploadForm extends Vue {
await this.initIfNecessary()
if (!this.signer) throw new Error('SIGNER_NOT_INITED');
if (!this.arweaveFeeTargetAddress) throw new Error('TARGET_ADDRESS_NOT_SET');
if (!this.arweaveFeeMap[record.ipfsHash]) throw new Error('ARWEAVE_FEE_NOT_SET');
this.uploadStatus = 'signing';
const memo = JSON.stringify({ ipfs: record.ipfsHash, fileSize: record.fileBlob?.size || 0 });
try {
const { transactionHash } = await sendLIKE(this.address, this.arweaveFeeTargetAddress, this.arweaveFee.toFixed(), this.signer, memo);
const { transactionHash } = await sendLIKE(this.address, this.arweaveFeeTargetAddress, this.arweaveFeeMap[record.ipfsHash], this.signer, memo);
if (transactionHash) {
const existingData = this.sentArweaveTransactionInfo.get(record.ipfsHash) || {};
this.sentArweaveTransactionInfo.set(record.ipfsHash, { ...existingData, transactionHash });
Expand Down

0 comments on commit 5207e88

Please sign in to comment.