Skip to content

Commit

Permalink
Merge branch 'develop' into fix/parse-deeplink-url-at-start
Browse files Browse the repository at this point in the history
  • Loading branch information
begonaalvarezd authored Nov 2, 2023
2 parents 1418091 + f405fd2 commit 9e33fe0
Show file tree
Hide file tree
Showing 24 changed files with 286 additions and 344 deletions.
23 changes: 1 addition & 22 deletions .github/ISSUE_TEMPLATE/create-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,4 @@ body:
label: Task description
description: Describe the task that needs to be completed.
validations:
required: true

- type: textarea
id: requirements
attributes:
label: Requirements
description: What are the requirements for this task, this could be a checklist of subtasks.
validations:
required: true

- type: checkboxes
id: checklist
attributes:
label: Creation checklist
description: 'Before submitting this task please ensure you have done the following if necessary:'
options:
- label: I have assigned this task to the correct people
required: false
- label: I have added the most appropriate labels
required: false
- label: I have linked the correct milestone and/or project
required: false
required: true
2 changes: 1 addition & 1 deletion .github/workflows/build-and-release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 18.15.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-desktop-test.v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
ref: 'main'

- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 14.x

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-desktop-test.v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 18.15.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 18.15.0

Expand Down
2 changes: 1 addition & 1 deletion packages/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "desktop",
"productName": "Firefly Shimmer",
"version": "2.1.8",
"version": "2.1.9",
"description": "Official wallet application of Shimmer",
"main": "public/build/main.js",
"repository": "[email protected]:iotaledger/firefly.git",
Expand Down
44 changes: 37 additions & 7 deletions packages/desktop/views/dashboard/vesting/Vesting.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
import { getMarketAmountFromAssetValue } from '@core/market/utils'
import { activeProfile } from '@core/profile'
import { getBestTimeDuration } from '@core/utils'
import { formatTokenAmountBestMatch, selectedAccountAssets } from '@core/wallet'
import {
formatTokenAmountBestMatch,
getRequiredStorageDepositForMinimalBasicOutput,
selectedAccountAssets,
} from '@core/wallet'
import {
Button,
FontWeight,
Expand All @@ -31,12 +35,18 @@
MeatballMenuButton,
TooltipIcon,
} from '@ui'
import { onMount } from 'svelte'
const DEFAULT_EMPTY_VALUE_STRING = '----'
$: hasTransactionInProgress =
$selectedAccount?.isTransferring || $selectedAccount.hasConsolidatingOutputsTransactionInProgress
let modal: Modal
let timeUntilNextPayout = DEFAULT_EMPTY_VALUE_STRING
let minRequiredStorageDeposit: number | null
let hasOutputsToConsolidate = false
$: ({ baseCoin } = $selectedAccountAssets[$activeProfile?.network?.id])
$: hasTransactionInProgress =
$selectedAccount?.isTransferring || $selectedAccount.hasConsolidatingOutputsTransactionInProgress
$: $selectedAccount, areOutputsReadyForConsolidation()
$: vestingOverview = [
{
title: localize('views.vesting.overview.unlocked'),
Expand All @@ -56,10 +66,30 @@
: undefined,
},
]
let modal: Modal
let timeUntilNextPayout = DEFAULT_EMPTY_VALUE_STRING
$: $selectedAccountVestingPayouts, (timeUntilNextPayout = getTimeUntilNextPayout())
$: canCollect =
$selectedAccountVestingUnclaimedFunds > 0 &&
!hasTransactionInProgress &&
minRequiredStorageDeposit !== null &&
$selectedAccount?.balances?.baseCoin?.available > minRequiredStorageDeposit &&
hasOutputsToConsolidate
onMount(() => {
getMinRequiredStorageDeposit()
})
function areOutputsReadyForConsolidation(): void {
$selectedAccount
.prepareConsolidateOutputs({ force: false, outputThreshold: 2 })
.then(() => (hasOutputsToConsolidate = true))
.catch(() => (hasOutputsToConsolidate = false))
}
function getMinRequiredStorageDeposit() {
getRequiredStorageDepositForMinimalBasicOutput()
.then((deposit) => (minRequiredStorageDeposit = deposit))
.catch(() => (minRequiredStorageDeposit = null))
}
function getFiatAmount(amount: number): string {
return baseCoin ? formatCurrency(getMarketAmountFromAssetValue(amount, baseCoin)) : ''
Expand Down Expand Up @@ -156,7 +186,7 @@
<Button
onClick={onCollectClick}
classes="w-full"
disabled={$selectedAccountVestingUnclaimedFunds === 0 || hasTransactionInProgress}
disabled={!canCollect}
isBusy={hasTransactionInProgress}
>
{localize('views.vesting.collect')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const FAQ_URL = 'https://wiki.iota.org/use/wallets/firefly/faq-and-troubleshooting'
export const FAQ_URL = 'https://firefly.iota.org/faq/'
52 changes: 35 additions & 17 deletions packages/shared/lib/core/layer-2/classes/special-stream.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,27 @@ export class SpecialStream extends WriteStream {

export class ReadSpecialStream extends ReadStream {
readUInt64SpecialEncoding(name: string): number | bigint {
const readValue = this.readBytes(name, 1)
const [value] = size64Decode(readValue)
const [value] = size64Decode(() => this.readUInt8(name))
return value
}

readUInt32SpecialEncoding(name: string): number | bigint {
const readValue = this.readBytes(name, 1)
const [value] = size64Decode(readValue)
const [value] = size64Decode(() => this.readUInt8(name))
return value
}
readUInt16SpecialEncoding(name: string): number | bigint {
const readValue = this.readBytes(name, 1)
const [value] = size64Decode(readValue)
const [value] = size64Decode(() => this.readUInt8(name))
return value
}

readUIntNSpecialEncoding(name: string, length: number): number | bigint {
const readValue = this.readBytes(name, length)
const [value] = size64Decode(readValue)
let index = 0
const [value] = size64Decode(() => {
const val = readValue[index]
index += 1
return val
})
return value
}
}
Expand Down Expand Up @@ -133,19 +136,34 @@ function size64Encode(n: bigint): Buffer {
}
}

function size64Decode(buffer: Uint8Array): [bigint, Error] | [number, null] {
let value = BigInt(0)
let shift = BigInt(0)
let index = 0
// Adapted from WASP golang implementation https://github.com/iotaledger/wasp/blob/7f880a7983d24d0dcd225e994d67b29741b318bc/packages/util/rwutil/convert.go#L76
function size64Decode(readByte: () => number): [number, null | Error] {
let byte = readByte()

if (byte < 0x80) {
return [byte, null]
}

let value = byte & 0x7f

while (index < buffer.length) {
const byte = buffer[index++]
for (let shift = 7; shift < 63; shift += 7) {
byte = readByte()
if (!byte) {
return [0, null]
}
if (byte < 0x80) {
return [Number(value | (BigInt(byte) << shift)), null]
return [Number(value | (byte << shift)), null]
}
value |= BigInt(byte & 0x7f) << shift
shift += BigInt(7)
value |= (byte & 0x7f) << shift
}

byte = readByte()
if (!byte) {
return [0, null]
}
if (byte > 0x01) {
return [0, new Error('size64 overflow')]
}

return [value, new Error('Unexpected end of data')]
return [value | (byte << 63), new Error('Unexpected end of data')]
}
Original file line number Diff line number Diff line change
@@ -1,62 +1,66 @@
import { Converter } from '@iota/util.js'
import { parseLayer2MetadataForTransferV2 } from '../utils/parseLayer2MetadataForTransferV2'
import { parseLayer2MetadataForTransfer } from '../utils/parseLayer2MetadataForTransfer'

describe('Function: parseLayer2MetadataForTransferV2.ts', () => {
describe('Function: parseLayer2MetadataForTransfer.ts', () => {
it('should correctly parse metadata with base token', () => {
const metadata = '0x00000000025e4b3ca1e3f423a0c21e0101611503807d707f59f1345e1063dbb64f2495d1491283a080c0843d'
const metadata =
'0x00025e4b3ca1e3f423914e010161350342f7da9bdb55b3ec87e5ac1a1e6d88e16768663fde5eca3429eb6f579cc538acb82a77d6f89dae4611b81eac279fbf96d322001f8080d293ad03'
const metadataByteArray = Converter.hexToBytes(metadata)
const expected = {
senderContract: '0x0',
targetContract: 'Accounts',
contractFunction: 'transferAllowanceTo',
gasBudget: '500000',
ethereumAddress: '0x807d707f59f1345e1063dbb64f2495d1491283a0',
baseTokens: '1000000',
gasBudget: '10001',
ethereumAddress:
'0x42f7da9bdb55b3ec87e5ac1a1e6d88e16768663fde5eca3429eb6f579cc538acb82a77d6f89dae4611b81eac279fbf96d322001f',
baseTokens: '900000000',
nativeTokens: [],
nfts: [],
}
const parsedMetadata = parseLayer2MetadataForTransferV2(metadataByteArray)
const parsedMetadata = parseLayer2MetadataForTransfer(metadataByteArray)
expect(parsedMetadata).toEqual(expected)
})

it('should correctly parse metadata with native tokens', () => {
const metadata =
'0x00000000025e4b3ca1e3f423a0c21e01016115038cc8112290f8c350a60e1afdb8379c686e2a5bb3400108fcccc313acc182fc2c647dc98864062b163a8ee254231d7f029dc6be3a2de52e01000000000132'
'0x00025e4b3ca1e3f423914e010161350342f7da9bdb55b3ec87e5ac1a1e6d88e16768663fde5eca3429eb6f579cc538acb82a77d6f89dae4611b81eac279fbf96d322001f4001086ac702fcfdc37b437e7ebb7a87d8acfb875be6b1ae3823bc61aa7896b852a6d5010000000001fa'
const metadataByteArray = Converter.hexToBytes(metadata)
const expected = {
senderContract: '0x0',
targetContract: 'Accounts',
contractFunction: 'transferAllowanceTo',
gasBudget: '500000',
ethereumAddress: '0x8cc8112290f8c350a60e1afdb8379c686e2a5bb3',
gasBudget: '10001',
ethereumAddress:
'0x42f7da9bdb55b3ec87e5ac1a1e6d88e16768663fde5eca3429eb6f579cc538acb82a77d6f89dae4611b81eac279fbf96d322001f',
baseTokens: '0',
nativeTokens: [
{
amount: '50',
ID: ['0x08fcccc313acc182fc2c647dc98864062b163a8ee254231d7f029dc6be3a2de52e0100000000'],
amount: '250',
ID: ['0x086ac702fcfdc37b437e7ebb7a87d8acfb875be6b1ae3823bc61aa7896b852a6d50100000000'],
},
],
nfts: [],
}
const parsedMetadata = parseLayer2MetadataForTransferV2(metadataByteArray)
const parsedMetadata = parseLayer2MetadataForTransfer(metadataByteArray)
expect(parsedMetadata).toEqual(expected)
})

it('should correctly parse metadata with nfts', () => {
const metadata =
'0x00000000025e4b3ca1e3f423a0c21e0101611503cbcd6d8659ed1998a452335ae53904dc0af1c99b200166b71141974aa368c9152a24d631494b46172ba05dd998eef553e7fa1218b704'
'0x00025e4b3ca1e3f423e9cd01010161350342f7da9bdb55b3ec87e5ac1a1e6d88e16768663fde5eca3429eb6f579cc538acb82a77d6f89dae4611b81eac279fbf96d322001f2001bf5b7cd4e8ac582e246c25b6a89b4ab4ef0646d3291aa03d9a5313154b714a06'
const metadataByteArray = Converter.hexToBytes(metadata)
const expected = {
senderContract: '0x0',
targetContract: 'Accounts',
contractFunction: 'transferAllowanceTo',
gasBudget: '500000',
ethereumAddress: '0xcbcd6d8659ed1998a452335ae53904dc0af1c99b',
gasBudget: '26345',
ethereumAddress:
'0x42f7da9bdb55b3ec87e5ac1a1e6d88e16768663fde5eca3429eb6f579cc538acb82a77d6f89dae4611b81eac279fbf96d322001f',
baseTokens: '0',
nativeTokens: [],
nfts: ['0x66b71141974aa368c9152a24d631494b46172ba05dd998eef553e7fa1218b704'],
nfts: ['0xbf5b7cd4e8ac582e246c25b6a89b4ab4ef0646d3291aa03d9a5313154b714a06'],
}
const parsedMetadata = parseLayer2MetadataForTransferV2(metadataByteArray)
const parsedMetadata = parseLayer2MetadataForTransfer(metadataByteArray)
expect(parsedMetadata).toEqual(expected)
})
})
2 changes: 0 additions & 2 deletions packages/shared/lib/core/layer-2/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export * from './getLayer2AssetAllowance'
export * from './getLayer2MetadataForTransfer'
export * from './getLayer2NetworkFromAddress'
export * from './parseLayer2Metadata'
export * from './parseLayer2MetadataForTransferV1'
export * from './parseLayer2MetadataForTransferV2'
export * from './parseLayer2MetadataForTransfer'
export * from './specialNativeTokenAmountEncoding'
export * from './outputHexBytes'
Loading

0 comments on commit 9e33fe0

Please sign in to comment.