Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register Operations logic #26

Merged
merged 27 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
60293fb
Updated deposit event logs
andreiblt1304 Jan 30, 2024
2fc2059
Generated empty MultiSigVerifier SC
andreiblt1304 Jan 31, 2024
e19c7a8
Fixed typo
andreiblt1304 Jan 30, 2024
10c82e7
Clippy fixes
andreiblt1304 Jan 30, 2024
c0fd739
Added register and sign functions
andreiblt1304 Feb 5, 2024
271518b
Added execute operation logic
andreiblt1304 Feb 7, 2024
1358570
WIP - Added mappers
andreiblt1304 Feb 12, 2024
e99746d
Fixed errors and added utils module
andreiblt1304 Feb 12, 2024
437203a
WIP - Modified register and exec logic
andreiblt1304 Feb 12, 2024
e5f7850
Removed execution logic
andreiblt1304 Feb 14, 2024
d639414
Moved logic to contract and added test setup
andreiblt1304 Feb 14, 2024
83c475f
Modified verification and registration logic
andreiblt1304 Feb 14, 2024
d45cd0c
Removed redundant code
andreiblt1304 Feb 15, 2024
e9c46a7
Added hash verification and deleted mandos
andreiblt1304 Feb 15, 2024
af301f0
Fixed comments
andreiblt1304 Feb 15, 2024
63b68eb
Added transfers_data array and test file
andreiblt1304 Feb 15, 2024
c20accf
Modified github workflows
andreiblt1304 Feb 15, 2024
e9c8129
Modified release github workflow
andreiblt1304 Feb 15, 2024
dfe9795
Fixed var_args and std errors
andreiblt1304 Feb 16, 2024
a191643
Added wasm folder
andreiblt1304 Feb 16, 2024
caa1fa8
Fixed comments
andreiblt1304 Feb 16, 2024
0788ebe
Added blackbox test
andreiblt1304 Feb 19, 2024
f323220
Added ops hash calculation and verification
andreiblt1304 Feb 19, 2024
bb4e2a5
Resolved actions merge conflict
ovidiuolteanu Feb 19, 2024
01091e6
Fixed hash of hashes method
andreiblt1304 Feb 19, 2024
2ab0e43
Deleted empty file
andreiblt1304 Feb 19, 2024
5391e54
Resolved clippy warnings
andreiblt1304 Feb 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@ name: CI

on:
push:
branches:
- main
branches: [ main, feat/* ]
pull_request:
branches: [ main, feat/* ]
workflow_dispatch:

permissions:
actions: write
checks: write
contents: write
id-token: write
issues: write
discussions: write
pull-requests: write
statuses: write

jobs:
contracts:
name: Contracts
uses: multiversx/mx-sc-actions/.github/workflows/[email protected].1
uses: multiversx/mx-sc-actions/.github/workflows/[email protected].5
with:
rust-toolchain: nightly-2023-05-26
vmtools-version: v1.4.60
rust-toolchain: nightly-2023-12-11
vmtools-version: v1.5.24
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 14 additions & 0 deletions .github/workflows/on_pull_request_build_contracts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: On pull request, build contracts

on:
pull_request:

permissions:
contents: write

jobs:
build:
uses: multiversx/mx-sc-actions/.github/workflows/[email protected]
with:
image_tag: v5.4.1
package_whole_project_src: true
78 changes: 7 additions & 71 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,79 +1,15 @@
name: Create release
name: On release build and attach artifacts

on:
workflow_dispatch:
inputs:
tag:
required: true
description: Release tag
title:
required: true
description: Release title
image_tag:
type: choice
required: true
description: Image multiversx/sdk-rust-contract-builder
options:
- v3.1.0
- v4.0.2
- v4.0.3
release:
types: [published]

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.GITHUB_REF_NAME }}
fetch-depth: 0
repository: ${{ env.GITHUB_REPOSITORY }}

- name: Download build script
run: |
wget https://raw.githubusercontent.com/multiversx/mx-sdk-rust-contract-builder/${{ github.event.inputs.image_tag }}/build_with_docker.py
- name: Build contract
run: |
python3 ./build_with_docker.py --no-docker-tty --image=multiversx/sdk-rust-contract-builder:${{ github.event.inputs.image_tag }} --project=. --output=/home/runner/work/output-from-docker
- name: Save artifacts
uses: actions/upload-artifact@v2
with:
name: built-contracts
path: |
/home/runner/work/output-from-docker/**/*.wasm
/home/runner/work/output-from-docker/**/*.abi.json
if-no-files-found: error

release:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: "0"

- name: Download all workflow artifacts
uses: actions/download-artifact@v2
with:
path: assets

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "Built using Docker image: **multiversx/sdk-rust-contract-builder:${{ github.event.inputs.image_tag }}**." >> notes.txt
echo "" >> notes.txt
echo "## Codehash (blake2b):" >> notes.txt
echo "" >> notes.txt
for i in $(find ./assets -type f -name *.wasm); do
filename=$(basename ${i})
checksum=($(b2sum -l 256 ${i}))
echo " - **${filename}**: \`${checksum}\`" >> notes.txt
done
gh release create ${{ github.event.inputs.tag }} --target=$GITHUB_SHA --prerelease --title="${{ github.event.inputs.title }}" --generate-notes --notes-file=notes.txt
sleep 10
gh release upload ${{ github.event.inputs.tag }} $(find ./assets -type f)
uses: multiversx/mx-sc-actions/.github/workflows/[email protected]
with:
image_tag: v6.0.0
attach_to_existing_release: true
8 changes: 4 additions & 4 deletions common/token-whitelist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub trait TokenWhitelistModule:
return;
}

let token_list = self.verfiy_items_signature(opt_signature, tokens);
let token_list = self.verify_items_signature(opt_signature, tokens);
self.token_whitelist().extend(&token_list);
}

Expand All @@ -39,7 +39,7 @@ pub trait TokenWhitelistModule:
return;
}

let token_list = self.verfiy_items_signature(opt_signature, tokens);
let token_list = self.verify_items_signature(opt_signature, tokens);
self.remove_items(&mut self.token_whitelist(), &token_list);
}

Expand All @@ -64,7 +64,7 @@ pub trait TokenWhitelistModule:
return;
}

let token_list = self.verfiy_items_signature(opt_signature, tokens);
let token_list = self.verify_items_signature(opt_signature, tokens);
self.token_blacklist().extend(&token_list);
}

Expand All @@ -81,7 +81,7 @@ pub trait TokenWhitelistModule:
return;
}

let token_list = self.verfiy_items_signature(opt_signature, tokens);
let token_list = self.verify_items_signature(opt_signature, tokens);
self.remove_items(&mut self.token_blacklist(), &token_list);
}

Expand Down
2 changes: 1 addition & 1 deletion common/utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub trait UtilsModule: bls_signature::BlsSignatureModule {
first_payment
}

fn verfiy_items_signature<T: TopDecode + NestedEncode + ManagedVecItem>(
fn verify_items_signature<T: TopDecode + NestedEncode + ManagedVecItem>(
&self,
opt_signature: Option<BlsSignature<Self::Api>>,
items: MultiValueEncoded<T>,
Expand Down
20 changes: 14 additions & 6 deletions esdt-safe/src/to_sovereign/create_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub trait CreateTxModule:
return;
}

let all_tokens = self.verfiy_items_signature(opt_signature, tokens);
let all_tokens = self.verify_items_signature(opt_signature, tokens);
self.burn_tokens().extend(&all_tokens);
}

Expand All @@ -74,7 +74,7 @@ pub trait CreateTxModule:
return;
}

let all_tokens = self.verfiy_items_signature(opt_signature, tokens);
let all_tokens = self.verify_items_signature(opt_signature, tokens);
self.remove_items(&mut self.burn_tokens(), &all_tokens);
}

Expand All @@ -91,7 +91,7 @@ pub trait CreateTxModule:
return;
}

let all_names = self.verfiy_items_signature(opt_signature, names);
let all_names = self.verify_items_signature(opt_signature, names);
self.banned_endpoint_names().extend(&all_names);
}

Expand All @@ -108,7 +108,7 @@ pub trait CreateTxModule:
return;
}

let all_names = self.verfiy_items_signature(opt_signature, names);
let all_names = self.verify_items_signature(opt_signature, names);
self.remove_items(&mut self.banned_endpoint_names(), &all_names);
}

Expand Down Expand Up @@ -151,6 +151,7 @@ pub trait CreateTxModule:
let own_sc_address = self.blockchain().get_sc_address();
let mut all_token_data = ManagedVec::new();
let mut total_tokens_for_fees = 0usize;
let mut event_payments = MultiValueEncoded::new();
let burn_mapper = self.burn_tokens();
for payment in &payments {
self.require_below_max_amount(&payment.token_identifier, &payment.amount);
Expand All @@ -170,6 +171,14 @@ pub trait CreateTxModule:
} else {
all_token_data.push(StolenFromFrameworkEsdtTokenData::default());
}

event_payments.push(
MultiValue3 ((
payment.token_identifier.clone(),
payment.token_nonce,
payment.amount.clone()
))
);

if burn_mapper.contains(&payment.token_identifier) {
self.send().esdt_local_burn(
Expand All @@ -196,8 +205,7 @@ pub trait CreateTxModule:

self.deposit_event(
&to,
&final_payments.fee,
&payments,
&event_payments,
DepositEvent::from(tx_nonce, &opt_transfer_data),
);

Expand Down
5 changes: 2 additions & 3 deletions esdt-safe/src/to_sovereign/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use transaction::{
transaction_status::TransactionStatus, BatchId, GasLimit, PaymentsVec, TransferData, TxId,
transaction_status::TransactionStatus, BatchId, GasLimit, TransferData, TxId
};

multiversx_sc::imports!();
Expand Down Expand Up @@ -38,8 +38,7 @@ pub trait EventsModule {
fn deposit_event(
&self,
#[indexed] dest_address: &ManagedAddress,
#[indexed] fee: &EsdtTokenPayment,
#[indexed] tokens: &PaymentsVec<Self::Api>,
#[indexed] tokens: &MultiValueEncoded<MultiValue3<TokenIdentifier, u64, BigUint>>,
event_data: DepositEvent<Self::Api>,
);

Expand Down
Loading
Loading