Skip to content

Commit

Permalink
Feat/vtoken voting vbnc (#1442)
Browse files Browse the repository at this point in the history
* Bifrost v0.12.0

* remove old migrations

* Fix vtokenVoting.removeDelegatorVote (#1288)

* add PollClass type

* add the calss parameter to the remove_delegator_vote method

* Add metadata hash (#1299)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Fix compile

* feat: 🎸 add metadata-hash-extension (#1265)

* feat: 🎸 add metadata-hash-extension

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Feat/add vtoken exchange rate rpc (#1277)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* supplement omissions: adjust the RPC exchange rate precision to three decimal places

* Remove dmp queue (#1279)

* fix: 🐛 CheckMetadataHash to false

* fix: 🐛 update sp-api

* refactor: 💡 fmt

* fix: 🐛 add metadata-hash

* fix: 🐛 add feature metadata-hash

* fix: 🐛 rm metadata-hash feature

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* refactor: 💡 update MaxTurnout and whitelisted_caller track (#1304)

* Allow to receive and send Ethereum assets (#1305)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* feat: 🎸 add metadata-hash-extension (#1265)

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Allow to receive and send Ethereum assets

* Add constants

---------

Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Disable supplement_fee_reserve (#1306)

* Remove call_switchgear and add tx_pause (#1308)

* Remove call_switchgear and add tx_pause

* Fix clippy

* Optimize flexible fee (#1307)

* Optimize flexible fee

* Fix bug

* Fix bug

* Add PalletId

* Add error handle

* feat: 🎸 add market-bond

* fix: 🐛 test-all

* fix: 🐛 try-runtime

* Add the channel_id field to the Minted event

* Upgrade to polkadot-v1.13.0 (#1312)

* Upgrade to polkadot-v1.13.0

* remove the warning

* Fix dep issues

* Upgrade to polkadot-v1.13.0

* supplement and upgrade the code

* Upgrade the new parts from v0.12.0

* Fix dep issues

* format Cargo.toml

* Modify the AddOrigin type of the fellowship in bifrost-polkadot

* Cancel the cross-in-out migration.

* fix clippy

---------

Co-authored-by: hqwangningbo <2536935847@qq.com>

* Use github dependencies (#1314)

* Fix flexible_fee TransferTo (#1315)

* Refactor code structure: extract the vote operation from the relaychain.

* Refactor code structure: extract the remove_vote operation from the relaychain.

* Move the XCM-related methods into the relaychain_agent.

* Move the call.rs into the relaychain_agent.

* vtokenvoting functionality supports vBNC

* Bifrost v0.13.0

* Remove getter in buy-back. (#1354)

* Bifrost v0.12.0

* remove old migrations

* Fix vtokenVoting.removeDelegatorVote (#1288)

* add PollClass type

* add the calss parameter to the remove_delegator_vote method

* Add metadata hash (#1299)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Fix compile

* feat: 🎸 add metadata-hash-extension (#1265)

* feat: 🎸 add metadata-hash-extension

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Feat/add vtoken exchange rate rpc (#1277)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* supplement omissions: adjust the RPC exchange rate precision to three decimal places

* Remove dmp queue (#1279)

* fix: 🐛 CheckMetadataHash to false

* fix: 🐛 update sp-api

* refactor: 💡 fmt

* fix: 🐛 add metadata-hash

* fix: 🐛 add feature metadata-hash

* fix: 🐛 rm metadata-hash feature

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* refactor: 💡 update MaxTurnout and whitelisted_caller track (#1304)

* Allow to receive and send Ethereum assets (#1305)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* feat: 🎸 add metadata-hash-extension (#1265)

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Allow to receive and send Ethereum assets

* Add constants

---------

Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Disable supplement_fee_reserve (#1306)

* Remove call_switchgear and add tx_pause (#1308)

* Remove call_switchgear and add tx_pause

* Fix clippy

* Optimize flexible fee (#1307)

* Optimize flexible fee

* Fix bug

* Fix bug

* Add PalletId

* Add error handle

* feat: 🎸 add market-bond

* fix: 🐛 test-all

* fix: 🐛 try-runtime

* Add the channel_id field to the Minted event

* Upgrade to polkadot-v1.13.0 (#1312)

* Upgrade to polkadot-v1.13.0

* remove the warning

* Fix dep issues

* Upgrade to polkadot-v1.13.0

* supplement and upgrade the code

* Upgrade the new parts from v0.12.0

* Fix dep issues

* format Cargo.toml

* Modify the AddOrigin type of the fellowship in bifrost-polkadot

* Cancel the cross-in-out migration.

* fix clippy

---------

Co-authored-by: hqwangningbo <2536935847@qq.com>

* Use github dependencies (#1314)

* Fix flexible_fee TransferTo (#1315)

* Fix generate_genesis_state (#1317)

* Optimize oracle (#1318)

* refactor: 💡 optimize orml-oracle

* fix: 🐛 MinimumTimestampInterval

* style: 💄 rename to MaximumValueInterval

* Add some tests for ve-minting

* Add some tests for ve-minting

* Integrate evm (#1319)

* Update dep

* Ingrate EVM

* Fix deps

* Add precompiles.rs

* Remove pallet-hotfix-sufficients

* Add pallet-evm-accounts

* Evm precompiles

* EVM integration

* Fix compile

* Fix rpc

* Fix `encode_evm_address` and `decode_evm_address`

* Fix evm precompile multicurrency

* Implementing Erc20Mapping using xc-20 standard

* Compatible with BNC Decimal

* Increase min_gas_price

* feat: enable dev mode with manual seal & fix pending block problem

* Add copyright and fix some bugs

* Change native token to WETH

* Support evm flexible fee

* Add inner_swap_exact_assets_for_assets to evm withdraw fee

* Remove swap

* EVM migration from bifrost kusama to bifrost polkadot

* Fix erc20 precompile

* Use OraclePrice

* Fix some errors

* feat: add prices genesis config & optimize dev mode code

* Fix conflicts

* Fix some errors

* Fix clippy

* Format Cargo.toml

* Remove unused code

* Fix clippy

* Fix some errors

* Fix erc20 precompile

---------

Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Fix try-runtime (#1323)

* Fix manual seal

* Fix manual seal (#1324)

* fix: 🐛 fellowship collective data (#1325)

* fix: add parachain mock inherent data provider

* Fix ethereum transfer fee (#1328)

* Add evm genesis migration (#1338)

* Bifrost v0.12.0 (#1286)

* Bifrost v0.12.0

* remove old migrations

* Fix vtokenVoting.removeDelegatorVote (#1288)

* add PollClass type

* add the calss parameter to the remove_delegator_vote method

* Add metadata hash (#1299)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Fix compile

* feat: 🎸 add metadata-hash-extension (#1265)

* feat: 🎸 add metadata-hash-extension

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Feat/add vtoken exchange rate rpc (#1277)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* supplement omissions: adjust the RPC exchange rate precision to three decimal places

* Remove dmp queue (#1279)

* fix: 🐛 CheckMetadataHash to false

* fix: 🐛 update sp-api

* refactor: 💡 fmt

* fix: 🐛 add metadata-hash

* fix: 🐛 add feature metadata-hash

* fix: 🐛 rm metadata-hash feature

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* refactor: 💡 update MaxTurnout and whitelisted_caller track (#1304)

* Allow to receive and send Ethereum assets (#1305)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* feat: 🎸 add metadata-hash-extension (#1265)

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Allow to receive and send Ethereum assets

* Add constants

---------

Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Disable supplement_fee_reserve (#1306)

* Remove call_switchgear and add tx_pause (#1308)

* Remove call_switchgear and add tx_pause

* Fix clippy

* Optimize flexible fee (#1307)

* Optimize flexible fee

* Fix bug

* Fix bug

* Add PalletId

* Add error handle

* feat: 🎸 add market-bond

* fix: 🐛 test-all

* fix: 🐛 try-runtime

* Add the channel_id field to the Minted event

* Upgrade to polkadot-v1.13.0 (#1312)

* Upgrade to polkadot-v1.13.0

* remove the warning

* Fix dep issues

* Upgrade to polkadot-v1.13.0

* supplement and upgrade the code

* Upgrade the new parts from v0.12.0

* Fix dep issues

* format Cargo.toml

* Modify the AddOrigin type of the fellowship in bifrost-polkadot

* Cancel the cross-in-out migration.

* fix clippy

---------

Co-authored-by: hqwangningbo <2536935847@qq.com>

* Use github dependencies (#1314)

* Fix flexible_fee TransferTo (#1315)

* Fix generate_genesis_state (#1317)

* Optimize oracle (#1318)

* refactor: 💡 optimize orml-oracle

* fix: 🐛 MinimumTimestampInterval

* style: 💄 rename to MaximumValueInterval

* Add some tests for ve-minting

* Add some tests for ve-minting

* Integrate evm (#1319)

* Update dep

* Ingrate EVM

* Fix deps

* Add precompiles.rs

* Remove pallet-hotfix-sufficients

* Add pallet-evm-accounts

* Evm precompiles

* EVM integration

* Fix compile

* Fix rpc

* Fix `encode_evm_address` and `decode_evm_address`

* Fix evm precompile multicurrency

* Implementing Erc20Mapping using xc-20 standard

* Compatible with BNC Decimal

* Increase min_gas_price

* feat: enable dev mode with manual seal & fix pending block problem

* Add copyright and fix some bugs

* Change native token to WETH

* Support evm flexible fee

* Add inner_swap_exact_assets_for_assets to evm withdraw fee

* Remove swap

* EVM migration from bifrost kusama to bifrost polkadot

* Fix erc20 precompile

* Use OraclePrice

* Fix some errors

* feat: add prices genesis config & optimize dev mode code

* Fix conflicts

* Fix some errors

* Fix clippy

* Format Cargo.toml

* Remove unused code

* Fix clippy

* Fix some errors

* Fix erc20 precompile

---------

Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Fix try-runtime (#1323)

* Fix manual seal

* Fix manual seal (#1324)

* fix: 🐛 fellowship collective data (#1325)

* fix: add parachain mock inherent data provider

* Fix ethereum transfer fee (#1328)

---------

Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Gemma <neversaynever333@outlook.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Add evm genesis storage

* [skip ci] Add evmSince

---------

Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: Gemma <neversaynever333@outlook.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Bump version to 0.12.1

* Update Cargo.lock

* Fix migration (#1341)

* Bifrost v0.12.0 (#1286)

* Bifrost v0.12.0

* remove old migrations

* Fix vtokenVoting.removeDelegatorVote (#1288)

* add PollClass type

* add the calss parameter to the remove_delegator_vote method

* Add metadata hash (#1299)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Fix compile

* feat: 🎸 add metadata-hash-extension (#1265)

* feat: 🎸 add metadata-hash-extension

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Feat/add vtoken exchange rate rpc (#1277)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* supplement omissions: adjust the RPC exchange rate precision to three decimal places

* Remove dmp queue (#1279)

* fix: 🐛 CheckMetadataHash to false

* fix: 🐛 update sp-api

* refactor: 💡 fmt

* fix: 🐛 add metadata-hash

* fix: 🐛 add feature metadata-hash

* fix: 🐛 rm metadata-hash feature

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* refactor: 💡 update MaxTurnout and whitelisted_caller track (#1304)

* Allow to receive and send Ethereum assets (#1305)

* feat: 🎸 add buy-back

* Bifrost v0.10.001

* feat: 🎸 benchmark

* SLPx mint support commission id (#1261)

* Add vtoken exchange rate rpc (#1260)

* fix: 🐛 add event (#1263)

* add update_currency_metadata function (#1259)

* add update_currency_metadata function

* fix: 🐛 correct update_currency_metadata weight

* add the use of Vec (#1264)

* Add vtoken exchange rate rpc

* add the use of Vec

* Upgrade to Polkadot-SDK v1.7.0 (#1262)

* Bifrost v0.10.0

* fix: 🐛 clippy

* Fix chain spec (#1243)

* Upgrade to polkadot-v1.7.0

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* feat: 🎸 add metadata-hash-extension (#1265)

* Fix compile (#1266)

* Fix/fix vtoken voting unlock (#1267)

* update the exchange rate of vtokenminting of vtokenvoting test

* Resolve the frozen anomaly when unlocking

* Revert "feat: 🎸 add metadata-hash-extension (#1265)" (#1268)

This reverts commit 489fc9c.

* rename the version number to 0.11.0

* Slp supports XCMv4 and reconstruct integration tests (#1272)

* Fix compile

* Reconstruct integration tests and slp supports XCMv4

* Fix slp construct_xcm_message

* Feat/slpx mint add commission (#1273)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* Feat/add vtoken exchange rate rpc (#1274)

* Add vtoken exchange rate rpc

* add the use of Vec

* supplement the RPC logic && fix bugs

* adjust the RPC exchange rate precision to three decimal places

* fix clippy

* fix bug: storage migration anomaly (#1276)

* SLPx mint support commission id

* remove the channel_id parameter from the mint method

* add mint_with_channel_id method

* perform data migration for OrderQueue storage

* slpx: set the default value of channel_id to 0

* resolve conflicts

* change the location of the old data structure during storage migration

* fix bug: storage migration anomaly

* Slp removes refund (#1275)

* Slp removes refund

* Fix clippy

* Allow to receive and send Ethereum assets

* Add constants

---------

Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>

* Disable supplement_fee_reserve (#1306)

* Remove call_switchgear and add tx_pause (#1308)

* Remove call_switchgear and add tx_pause

* Fix clippy

* Optimize flexible fee (#1307)

* Optimize flexible fee

* Fix bug

* Fix bug

* Add PalletId

* Add error handle

* feat: 🎸 add market-bond

* fix: 🐛 test-all

* fix: 🐛 try-runtime

* Add the channel_id field to the Minted event

* Upgrade to polkadot-v1.13.0 (#1312)

* Upgrade to polkadot-v1.13.0

* remove the warning

* Fix dep issues

* Upgrade to polkadot-v1.13.0

* supplement and upgrade the code

* Upgrade the new parts from v0.12.0

* Fix dep issues

* format Cargo.toml

* Modify the AddOrigin type of the fellowship in bifrost-polkadot

* Cancel the cross-in-out migration.

* fix clippy

---------

Co-authored-by: hqwangningbo <2536935847@qq.com>

* Use github dependencies (#1314)

* Fix flexible_fee TransferTo (#1315)

* Fix generate_genesis_state (#1317)

* Optimize oracle (#1318)

* refactor: 💡 optimize orml-oracle

* fix: 🐛 MinimumTimestampInterval

* style: 💄 rename to MaximumValueInterval

* Add some tests for ve-minting

* Add some tests for ve-minting

* Integrate evm (#1319)

* Update dep

* Ingrate EVM

* Fix deps

* Add precompiles.rs

* Remove pallet-hotfix-sufficients

* Add pallet-evm-accounts

* Evm precompiles

* EVM integration

* Fix compile

* Fix rpc

* Fix `encode_evm_address` and `decode_evm_address`

* Fix evm precompile multicurrency

* Implementing Erc20Mapping using xc-20 standard

* Compatible with BNC Decimal

* Increase min_gas_price

* feat: enable dev mode with manual seal & fix pending block problem

* Add copyright and fix some bugs

* Change native token to WETH

* Support evm flexible fee

* Add inner_swap_exact_assets_for_assets to evm withdraw fee

* Remove swap

* EVM migration from bifrost kusama to bifrost polkadot

* Fix erc20 precompile

* Use OraclePrice

* Fix some errors

* feat: add prices genesis config & optimize dev mode code

* Fix conflicts

* Fix some errors

* Fix clippy

* Format Cargo.toml

* Remove unused code

* Fix clippy

* Fix some errors

* Fix erc20 precompile

---------

Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Fix try-runtime (#1323)

* Fix manual seal

* Fix manual seal (#1324)

* fix: 🐛 fellowship collective data (#1325)

* fix: add parachain mock inherent data provider

* Fix ethereum transfer fee (#1328)

---------

Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Gemma <neversaynever333@outlook.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Add evm genesis storage

* [skip ci] Add evmSince

* Fix migration

* Fix migration

* Remove unused code

---------

Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: Gemma <neversaynever333@outlook.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Remove getter in buy-back

---------

Co-authored-by: SunTiebing <1045060705@qq.com>
Co-authored-by: SunTiebing <87381708+SunTiebing@users.noreply.github.com>
Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>

* Remove getters in xcm-interface (#1352)

* Remove getters in salp. (#1351)

* Remove getter in evm-accounts (#1350)

* Remove getters in slp (#1353)

* Remove getters in slpx (#1360)

* Remove getters in vstoken-conversion. (#1362)

* Remove getters in vtoken-minting. (#1363)

* Remove getter in system-maker. (#1364)

* Remove getter in fee-share (#1365)

* Remove getters in prices (#1367)

* Remove getters in lend-market (#1366)

* Remove getters in ve-minting (#1368)

* Optimize clippy (#1369)

* Deprecated unused pallets (#1383)

* Review format (#1386)

* style: 💄 format

* style: 💄 check-all

* fix: 🐛 bench

* Update buy back (#1387)

* style: 💄 format

* style: 💄 check-all

* fix: 🐛 bench

* feat: 🎸 add destruction_ratio

* fix: 🐛 benchmark

* EVM flexible fee logic optimization (#1370)

* EVM flexible fee logic optimization

* Add comments

* Add support for handling different currency precisions & included error handling.

* Adjust the gas_fee parameter in the get_balance_in_currency method to an exact value

* fix clippy

* add test code of flexiable-fee pallet

* Update fee share (#1395)

* feat: 🎸 add usd_cumulation

* feat: 🎸 bench

* fix: 🐛 fmt

* docs: ✏️ add note

* Feat/change evm address convert rule (#1396)

* Change EVM Address convert rule

* Change EVM Address convert rule

* Remove the unused function:is_evm_account & rename truncated_account_id function to convert_account_id

* fix clippy

* refactor: 💡 move to TechAdmin (#1398)

* refactor: 💡 transfer to BuyBackAccount (#1399)

* Fix mint_with_channel_id weights (#1400)

* Recoverd imgs of banner and logo (#1401)

* feat: 🎸 add fn set_swap_out_min (#1389)

* feat: 🎸 add fn set_swap_out_min

* fix: 🐛 fmt

* fix: 🐛 fmt

* fix: 🐛 error

* feat: 🎸 add bais

* fix: 🐛 add test

* fix: 🐛 rename field bias

* Optimize the `channel-commission` code. (#1390)

* Optimize the `channel-commission` code.

* Replace the insert method with the mutate method

* Added a result check for the clear_prefix method

* Supplement the test code of `channel-commission`.

* Handling Error cases in hooks.

* Optimize the handling of the `check_removed_all` method.

* Remove getters in cross-in-out (#1402)

* Removed getters in channel-commission. (#1404)

* Removed getters in flexible-fee. (#1405)

* Removed getters in channel-commission.

* Removed getters in flexible-fee.

* Removed getters in parachain-staking. (#1406)

* Removed getters in channel-commission.

* Removed getters in flexible-fee.

* Removed getterd in parachain-staking.

* Update buy back (#1407)

* fix: 🐛 add field last_buyback_cycle for accurate judgment

* style: 💄 fmt

* Update ve minting (#1408)

* refactor: 💡 transfer to BuyBackAccount

* feat: 🎸 add auto notify_reward

* Optimize vtokenvoting pallet.

* Use the call.dispatch method to support vBNC in vTokenVoting.

* Use the call.dispatch method to support vBNC in vTokenVoting.

* adjust mock file

* Change the way the vtoken-voting pallet interacts with other runtime pallets to a decoding-based approach.

* Plump vtokenvoting supports vbnc

* optimize test

* optimize reviewed code

* Add vtoken-voting Kusama tests to the test-all command.

---------

Co-authored-by: Edwin Wang <lark930@gmail.com>
Co-authored-by: yooml <ymlll0508@gmail.com>
Co-authored-by: NingBo Wang <2536935847@qq.com>
Co-authored-by: MJLNSN <96321798+MJLNSN@users.noreply.github.com>
Co-authored-by: Damian.lu <wsteth@outlook.com>
  • Loading branch information
6 people authored Sep 30, 2024
1 parent 72b00f4 commit c97cdc2
Show file tree
Hide file tree
Showing 21 changed files with 3,526 additions and 1,633 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ check-all: format
SKIP_WASM_BUILD= cargo check -p bifrost-cli --locked --features "with-all-runtime,runtime-benchmarks,try-runtime"

.PHONY: test-all # cargo test all
test-all: test-runtimes test-benchmarks
test-all: test-runtimes test-benchmarks test-vtoken-voting-kusama

.PHONY: test-runtimes
test-runtimes:
Expand All @@ -40,6 +40,9 @@ test-runtimes:
test-benchmarks:
SKIP_WASM_BUILD= cargo test benchmarking --features="with-bifrost-runtime, runtime-benchmarks, polkadot"

test-vtoken-voting-kusama:
SKIP_WASM_BUILD= cargo test -p bifrost-vtoken-voting --features="kusama, runtime-benchmarks"

.PHONY: clean # cargo clean
clean:
cargo clean
Expand Down
15 changes: 14 additions & 1 deletion pallets/slp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,8 @@ pub mod pallet {
pub struct DerivativeAccountProvider<T, F>(PhantomData<(T, F)>);

impl<T: Config, F: Contains<CurrencyIdOf<T>>>
DerivativeAccountHandler<CurrencyIdOf<T>, BalanceOf<T>> for DerivativeAccountProvider<T, F>
DerivativeAccountHandler<CurrencyIdOf<T>, BalanceOf<T>, AccountIdOf<T>>
for DerivativeAccountProvider<T, F>
{
fn check_derivative_index_exists(
token: CurrencyIdOf<T>,
Expand All @@ -2270,6 +2271,18 @@ impl<T: Config, F: Contains<CurrencyIdOf<T>>>
DelegatorsIndex2Multilocation::<T>::get(token, derivative_index)
}

fn get_account_id(
token: CurrencyIdOf<T>,
derivative_index: DerivativeIndex,
) -> Option<AccountIdOf<T>> {
Self::get_multilocation(token, derivative_index).and_then(|location| {
location.interior.last().and_then(|interior| match interior {
AccountId32 { id, .. } => T::AccountId::decode(&mut &id[..]).ok(),
_ => None,
})
})
}

fn get_stake_info(
token: CurrencyIdOf<T>,
derivative_index: DerivativeIndex,
Expand Down
2 changes: 1 addition & 1 deletion pallets/vtoken-minting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ impl<T: Config> VTokenSupplyProvider<CurrencyIdOf<T>, BalanceOf<T>> for Pallet<T
}

fn get_token_supply(token: CurrencyIdOf<T>) -> Option<BalanceOf<T>> {
if CurrencyId::is_token(&token) {
if CurrencyId::is_token(&token) | CurrencyId::is_native(&token) {
Some(TokenPool::<T>::get(token))
} else {
None
Expand Down
150 changes: 150 additions & 0 deletions pallets/vtoken-voting/src/agents/bifrost_agent/agent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::*;
use bifrost_primitives::{CurrencyId, DerivativeIndex};
use frame_support::pallet_prelude::*;
use xcm::v4::Location;

use crate::{agents::bifrost_agent::BifrostCall, pallet::Error, traits::*};

/// VotingAgent implementation for Bifrost
pub struct BifrostAgent<T: Config> {
vtoken: CurrencyIdOf<T>,
location: Location,
}

impl<T: Config> BifrostAgent<T> {
// Only polkadot networks are supported.
pub fn new(vtoken: CurrencyId) -> Result<Self, Error<T>> {
if cfg!(feature = "polkadot") {
let location = Pallet::<T>::convert_vtoken_to_dest_location(vtoken)?;
Ok(Self { vtoken, location })
} else {
Err(Error::<T>::VTokenNotSupport)
}
}
}

impl<T: Config> VotingAgent<T> for BifrostAgent<T> {
fn vtoken(&self) -> CurrencyIdOf<T> {
self.vtoken
}

fn location(&self) -> Location {
self.location.clone()
}

fn delegate_vote(
&self,
who: AccountIdOf<T>,
vtoken: CurrencyIdOf<T>,
poll_index: PollIndex,
_submitted: bool,
new_delegator_votes: Vec<(DerivativeIndex, AccountVote<BalanceOf<T>>)>,
maybe_old_vote: Option<(AccountVote<BalanceOf<T>>, BalanceOf<T>)>,
) -> DispatchResult {
// Get the derivative index from the first delegator vote.
let derivative_index = new_delegator_votes[0].0;
let call_encode =
self.vote_call_encode(new_delegator_votes, poll_index, derivative_index)?;
let vote_call: <T as frame_system::Config>::RuntimeCall =
<T as frame_system::Config>::RuntimeCall::decode(&mut &*call_encode)
.map_err(|_| Error::<T>::CallDecodeFailed)?;

let token = CurrencyId::to_token(&vtoken).map_err(|_| Error::<T>::NoData)?;
let delegator: AccountIdOf<T> =
T::DerivativeAccount::get_account_id(token, derivative_index)
.ok_or(Error::<T>::NoData)?;
let origin = RawOrigin::Signed(delegator).into();
let success = vote_call.dispatch(origin).is_ok();
Pallet::<T>::handle_vote_result(
success,
who,
vtoken,
poll_index,
maybe_old_vote,
derivative_index,
)?;

if success {
Ok(())
} else {
Err(Error::<T>::InvalidCallDispatch.into())
}
}

fn vote_call_encode(
&self,
new_delegator_votes: Vec<(DerivativeIndex, AccountVote<BalanceOf<T>>)>,
poll_index: PollIndex,
_derivative_index: DerivativeIndex,
) -> Result<Vec<u8>, Error<T>> {
let vote_calls = new_delegator_votes
.iter()
.map(|(_derivative_index, vote)| {
<BifrostCall<T> as ConvictionVotingCall<T>>::vote(poll_index, *vote)
})
.collect::<Vec<_>>();
let vote_call = if vote_calls.len() == 1 {
vote_calls.into_iter().nth(0).ok_or(Error::<T>::NoData)?
} else {
ensure!(false, Error::<T>::NoPermissionYet);
<BifrostCall<T> as UtilityCall<BifrostCall<T>>>::batch_all(vote_calls)
};

Ok(vote_call.encode())
}

fn delegate_remove_delegator_vote(
&self,
vtoken: CurrencyIdOf<T>,
poll_index: PollIndex,
class: PollClass,
derivative_index: DerivativeIndex,
) -> DispatchResult {
let call_encode =
self.remove_delegator_vote_call_encode(class, poll_index, derivative_index)?;
let call = <T as frame_system::Config>::RuntimeCall::decode(&mut &*call_encode)
.map_err(|_| Error::<T>::CallDecodeFailed)?;

let token = CurrencyId::to_token(&vtoken).map_err(|_| Error::<T>::NoData)?;
let delegator: AccountIdOf<T> =
T::DerivativeAccount::get_account_id(token, derivative_index)
.ok_or(Error::<T>::NoData)?;
let origin = RawOrigin::Signed(delegator).into();
let success = call.dispatch(origin).is_ok();

if success {
Pallet::<T>::handle_remove_delegator_vote_success(vtoken, poll_index);
Ok(())
} else {
Err(Error::<T>::InvalidCallDispatch.into())
}
}

fn remove_delegator_vote_call_encode(
&self,
class: PollClass,
poll_index: PollIndex,
_derivative_index: DerivativeIndex,
) -> Result<Vec<u8>, Error<T>> {
Ok(<BifrostCall<T> as ConvictionVotingCall<T>>::remove_vote(Some(class), poll_index)
.encode())
}
}
73 changes: 73 additions & 0 deletions pallets/vtoken-voting/src/agents/bifrost_agent/call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use crate::{traits::*, *};
use parity_scale_codec::{Decode, Encode};
use sp_runtime::{traits::StaticLookup, RuntimeDebug};

pub(in crate::agents::bifrost_agent) use bifrost::*;

pub(in crate::agents::bifrost_agent) mod bifrost {
use crate::agents::bifrost_agent::call::*;

#[derive(Encode, Decode, RuntimeDebug)]
pub(in crate::agents::bifrost_agent) enum BifrostCall<T: Config> {
#[codec(index = 36)]
ConvictionVoting(ConvictionVoting<T>),
#[codec(index = 50)]
Utility(Utility<Self>),
}
}

#[derive(Encode, Decode, RuntimeDebug, Clone)]
pub(in crate::agents::bifrost_agent) enum ConvictionVoting<T: Config> {
#[codec(index = 0)]
Vote(#[codec(compact)] PollIndex, AccountVote<BalanceOf<T>>),
#[codec(index = 3)]
Unlock(PollClass, <T::Lookup as StaticLookup>::Source),
#[codec(index = 4)]
RemoveVote(Option<PollClass>, PollIndex),
}

impl<T: Config> ConvictionVotingCall<T> for BifrostCall<T> {
fn vote(poll_index: PollIndex, vote: AccountVote<BalanceOf<T>>) -> Self {
Self::ConvictionVoting(ConvictionVoting::Vote(poll_index, vote))
}

fn remove_vote(class: Option<PollClass>, poll_index: PollIndex) -> Self {
Self::ConvictionVoting(ConvictionVoting::RemoveVote(class, poll_index))
}
}

#[derive(Encode, Decode, RuntimeDebug, Clone)]
pub(in crate::agents::bifrost_agent) enum Utility<Call> {
#[codec(index = 1)]
AsDerivative(DerivativeIndex, Box<Call>),
#[codec(index = 2)]
BatchAll(Vec<Call>),
}

impl<T: Config> UtilityCall<BifrostCall<T>> for BifrostCall<T> {
fn as_derivative(derivative_index: DerivativeIndex, call: Self) -> Self {
Self::Utility(Utility::AsDerivative(derivative_index, Box::new(call)))
}

fn batch_all(calls: Vec<Self>) -> Self {
Self::Utility(Utility::BatchAll(calls))
}
}
22 changes: 22 additions & 0 deletions pallets/vtoken-voting/src/agents/bifrost_agent/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
pub mod agent;
mod call;

pub use agent::*;
pub(in crate::agents::bifrost_agent) use call::*;
23 changes: 23 additions & 0 deletions pallets/vtoken-voting/src/agents/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

mod bifrost_agent;
mod relaychain_agent;

pub use bifrost_agent::*;
pub use relaychain_agent::*;
Loading

0 comments on commit c97cdc2

Please sign in to comment.