Skip to content

Commit

Permalink
chore: merge origin/main
Browse files Browse the repository at this point in the history
  • Loading branch information
kieranroneill committed Oct 18, 2024
2 parents 99ab9b9 + cb5af47 commit d5bdcb3
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 40 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ body:
label: Version
description: What version of the software are you running?
options:
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/deploy_dapp_example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ on:
- beta

jobs:
install:
name: "Install"
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies
- name: "🏗️ Build"
run: yarn build:dapp-example
- name: "📤 Upload artifact"
uses: actions/upload-pages-artifact@v3
with:
path: ./.dapp_example_build

deploy:
name: "Deploy"
needs: [install]
needs: build
permissions:
pages: write # to deploy to pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: "🛎 Checkout"
uses: actions/checkout@v4
- name: "🔧 Setup"
uses: ./.github/actions/use-dependencies
- name: "🏗️ Build"
run: yarn build:dapp-example
- name: "🚀 Deploy"
uses: peaceiris/actions-gh-pages@v3
with:
force_orphan: true # create empty branch if missing
personal_token: ${{ secrets.WRITE_REPOS_TOKEN }}
publish_branch: gh-pages
publish_dir: ./.dapp_example_build
user_name: agoralabs-bot
user_email: [email protected]
id: deployment
uses: actions/deploy-pages@v4
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [2.3.2](https://github.com/kibis-is/web-extension/compare/v2.3.1...v2.3.2) (2024-10-18)


### Bug Fixes

* ignore non-utf-8 encoded notes ([#341](https://github.com/kibis-is/web-extension/issues/341)) ([a24d369](https://github.com/kibis-is/web-extension/commit/a24d3695c61c485f49254ca78682ee00af4e2aed))

# [2.4.0-beta.2](https://github.com/kibis-is/web-extensiontension/compare/v2.4.0-beta.1...v2.4.0-beta.2) (2024-10-03)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { decode as decodeBase64 } from '@stablelib/base64';
import { decode as decodeUtf8 } from '@stablelib/utf8';
import { BigNumber } from 'bignumber.js';

// enums
Expand All @@ -18,59 +16,58 @@ import parseAssetConfigTransaction from './parseAssetConfigTransaction';
import parseAssetFreezeTransaction from './parseAssetFreezeTransaction';
import parseAssetTransferTransaction from './parseAssetTransferTransaction';
import parseKeyRegistrationTransaction from './parseKeyRegistrationTransaction';
import parseNote from './parseNote';
import parsePaymentAndReKeyTransaction from './parsePaymentAndReKeyTransaction';

export default function mapAlgorandTransactionToTransaction(
algorandTransaction: IAlgorandTransaction
avmTransaction: IAlgorandTransaction
): ITransactions {
const baseTransaction: IBaseTransaction = {
authAddr: algorandTransaction['auth-addr'] || null,
completedAt: algorandTransaction['round-time']
? new BigNumber(String(algorandTransaction['round-time'] as bigint))
authAddr: avmTransaction['auth-addr'] || null,
completedAt: avmTransaction['round-time']
? new BigNumber(String(avmTransaction['round-time'] as bigint))
.multipliedBy(1000) // we want milliseconds, as 'round-time' is in seconds
.toNumber()
: null,
fee: new BigNumber(String(algorandTransaction.fee as bigint)).toFixed(),
id: algorandTransaction.id || null,
genesisHash: algorandTransaction['genesis-hash'] || null,
groupId: algorandTransaction.group || null,
note: algorandTransaction.note
? decodeUtf8(decodeBase64(algorandTransaction.note))
: null,
rekeyTo: algorandTransaction['rekey-to'] || null,
sender: algorandTransaction.sender,
fee: new BigNumber(String(avmTransaction.fee as bigint)).toFixed(),
id: avmTransaction.id || null,
genesisHash: avmTransaction['genesis-hash'] || null,
groupId: avmTransaction.group || null,
note: avmTransaction.note ? parseNote(avmTransaction.note) : null,
rekeyTo: avmTransaction['rekey-to'] || null,
sender: avmTransaction.sender,
};

switch (algorandTransaction['tx-type']) {
switch (avmTransaction['tx-type']) {
case 'acfg':
return parseAssetConfigTransaction(
algorandTransaction['asset-config-transaction'],
avmTransaction['asset-config-transaction'],
baseTransaction
);
case 'afrz':
return parseAssetFreezeTransaction(
algorandTransaction['asset-freeze-transaction'],
avmTransaction['asset-freeze-transaction'],
baseTransaction
);
case 'appl':
return parseApplicationTransaction(
algorandTransaction['application-transaction'],
avmTransaction['application-transaction'],
baseTransaction,
algorandTransaction['inner-txns']
avmTransaction['inner-txns']
);
case 'axfer':
return parseAssetTransferTransaction(
algorandTransaction['asset-transfer-transaction'],
avmTransaction['asset-transfer-transaction'],
baseTransaction
);
case 'keyreg':
return parseKeyRegistrationTransaction(
algorandTransaction['keyreg-transaction'],
avmTransaction['keyreg-transaction'],
baseTransaction
);
case 'pay':
return parsePaymentAndReKeyTransaction(
algorandTransaction['payment-transaction'],
avmTransaction['payment-transaction'],
baseTransaction
);
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { decode as decodeBase64 } from '@stablelib/base64';
import { decode as decodeUtf8 } from '@stablelib/utf8';

// types
import type { IBaseOptions } from '@common/types';

/**
* Parses the note field. The note field will be encoded in base64 and this function will attempt to decode to UTF-8. If
* the note field is not in UTF-8 format, it gracefully errors and returns null.
* @param {string} encodedNote - The note field encoded in base64.
* @param {IBaseOptions} options - [optional] Base options that include the logger for logging.
* @returns {string | null} The decoded note field or null if UTF-8 decoding failed.
*/
export default function parseNote(
encodedNote: string,
options?: IBaseOptions
): string | null {
const _functionName = 'parseNote';

try {
return decodeUtf8(
decodeBase64(encodedNote) // decode from base64
);
} catch (error) {
options?.logger?.debug(`${_functionName}: note not encoded in utf-8`);

return null;
}
}

0 comments on commit d5bdcb3

Please sign in to comment.