Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Jul 9, 2024
2 parents 7b99940 + 03c9d7b commit cf66841
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 3 deletions.
2 changes: 1 addition & 1 deletion move/axelar_gateway/Move.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[move]
version = 2
manifest_digest = "B3F1114AF6420DAFC5501B8A333236271B0467A5D00AF701F02D79AEC565E6E5"
manifest_digest = "1EB54C26C3FA638760DAA54E631C0B13A09FFC472C1CAA730C9A7879E463B455"
deps_digest = "F8BBB0CCB2491CA29A3DF03D6F92277A4F3574266507ACD77214D37ECA3F3082"
dependencies = [
{ name = "Sui" },
Expand Down
3 changes: 1 addition & 2 deletions move/axelar_gateway/Move.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[package]
name = "AxelarGateway"
version = "0.1.0"
published-at = "0x571841ce66dce70e51a123299ed140d6509566c97eb905331b5f28732c707c56"
edition = "2024.beta"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "mainnet-v1.25.3" }

[addresses]
axelar_gateway = "0xdd3b165835ec3d510016f8492519feb74a631f235f0126f44fec079c8aa81186"
axelar_gateway = "0xcd391ade5ab55a218f8988df8f3aa38ec019651c217244f7f689616c87d8c289"
clock = "0x6"
122 changes: 122 additions & 0 deletions scripts/bcs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const { bcs } = require('@mysten/sui.js/bcs');

function getAxelarStructs() {
const Bytes32 = bcs.struct('Bytes32', {
bytes: bcs.Address,
});

const Message = bcs.struct('Message', {
source_chain: bcs.String,
message_id: bcs.String,
source_address: bcs.String,
destination_id: bcs.Address,
payload_hash: Bytes32,
});

const WeightedSigner = bcs.struct('WeightedSigner', {
pubkey: bcs.vector(bcs.U8),
weight: bcs.U128,
});

const WeightedSigners = bcs.struct('WeightedSigners', {
signers: bcs.vector(WeightedSigner),
threshold: bcs.U128,
nonce: Bytes32,
});

const Signature = bcs.struct('Signature', {
bytes: bcs.vector(bcs.U8),
});

const Proof = bcs.struct('Proof', {
signers: WeightedSigners,
signatures: bcs.vector(Signature),
});

const MessageToSign = bcs.struct('MessageToSign', {
domain_separator: Bytes32,
signers_hash: Bytes32,
data_hash: Bytes32,
});

const Function = bcs.struct('Function', {
package_id: bcs.Address,
module_name: bcs.String,
name: bcs.String,
});

/// Arguments are prefixed with:
/// - 0 for objects followed by exactly 32 bytes that cointain the object id
/// - 1 for pures followed by the bcs encoded form of the pure
/// - 2 for the call contract object, followed by nothing (to be passed into the target function)
/// - 3 for the payload of the contract call (to be passed into the intermediate function)
/// - 4 for an argument returned from a previous move call, followed by a u8 specified which call to get the return of (0 for the first transaction AFTER the one that gets ApprovedMessage out), and then another u8 specifying which argument to input.
const MoveCall = bcs.struct('MoveCall', {
function: Function,
arguments: bcs.vector(bcs.vector(bcs.U8)),
type_arguments: bcs.vector(bcs.String),
});

const Transaction = bcs.struct('Transaction', {
is_final: bcs.Bool,
move_calls: bcs.vector(MoveCall),
});

const EncodedMessage = bcs.struct('EncodedMessage', {
message_type: bcs.U8,
data: bcs.vector(bcs.U8),
});

return {
Bytes32,
Message,
WeightedSigner,
WeightedSigners,
Signature,
Proof,
MessageToSign,
Function,
MoveCall,
Transaction,
EncodedMessage,
};
}

function getSquidStructs() {
const DeepbookV2SwapData = bcs.struct('DeepbookV2SwapData', {
swap_type: bcs.U8,
pool_id: bcs.Address,
has_base: bcs.Bool,
min_output: bcs.U64,
base_type: bcs.String,
quote_type: bcs.String,
lot_size: bcs.U64,
should_sweep: bcs.Bool,
});

const SuiTransferSwapData = bcs.struct('SuiTransferSwapData', {
swap_type: bcs.U8,
coin_type: bcs.String,
recipient: bcs.Address,
});

const ItsTransferSwapData = bcs.struct('ItsTransferSwapData', {
swap_type: bcs.U8,
coin_type: bcs.String,
token_id: bcs.Address,
destination_chain: bcs.String,
destination_address: bcs.vector(bcs.U8),
metadata: bcs.vector(bcs.U8),
});

return {
DeepbookV2SwapData,
SuiTransferSwapData,
ItsTransferSwapData,
};
}

module.exports = {
axelarStructs: getAxelarStructs(),
squidStructs: getSquidStructs(),
};
1 change: 1 addition & 0 deletions scripts/tx-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class TxBuilder {
...options,
},
});

return result;
}

Expand Down

0 comments on commit cf66841

Please sign in to comment.