From 4e2be40c88af97465c272043d2f2aaa64b500300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Tue, 26 Aug 2025 12:09:42 +0200 Subject: [PATCH 1/2] SDK/bindings: use directly operation content for wrapping operation Instead of redefining its fields in the wrapper --- contrib/sdk-bindings/rust/src/forge.rs | 208 +++++++++---------------- 1 file changed, 70 insertions(+), 138 deletions(-) diff --git a/contrib/sdk-bindings/rust/src/forge.rs b/contrib/sdk-bindings/rust/src/forge.rs index 1a9ee72e3363..f27092619aab 100644 --- a/contrib/sdk-bindings/rust/src/forge.rs +++ b/contrib/sdk-bindings/rust/src/forge.rs @@ -66,15 +66,7 @@ pub mod operation { }; #[derive(uniffi::Object, Debug)] - pub struct Reveal { - pub source: PublicKeyHash, - pub fee: u64, - pub counter: u64, - pub gas_limit: u64, - pub storage_limit: u64, - pub public_key: PublicKey, - pub proof: Option, - } + pub struct Reveal(ManagerOperationContent); #[uniffi::export] impl Reveal { @@ -89,48 +81,29 @@ pub mod operation { public_key: &PublicKey, proof: Option>, ) -> Self { - Self { - source: source.clone(), - fee, - counter, - gas_limit, - storage_limit, - public_key: public_key.clone(), - proof: proof.map(|proof| proof.as_ref().clone()), - } + Self(ManagerOperationContent { + source: source.0.clone(), + fee: fee.into(), + counter: counter.into(), + gas_limit: gas_limit.into(), + storage_limit: storage_limit.into(), + operation: RevealContent { + pk: public_key.0.clone(), + proof: proof.map(|proof| proof.0.clone()), + }, + }) } #[doc = "Forge the operation."] pub fn forge(&self) -> Result, Error> { - let reveal = OperationContent::Reveal(ManagerOperationContent { - source: self.source.0.clone(), - fee: self.fee.into(), - counter: self.counter.into(), - gas_limit: self.gas_limit.into(), - storage_limit: self.storage_limit.into(), - operation: RevealContent { - pk: self.public_key.0.clone(), - proof: self.proof.clone().map(|proof| proof.0), - }, - }); - reveal + OperationContent::Reveal(self.0.clone()) .to_bytes() .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) } } #[derive(uniffi::Object, Debug)] - pub struct Transaction { - pub source: PublicKeyHash, - pub fee: u64, - pub counter: u64, - pub gas_limit: u64, - pub storage_limit: u64, - pub amount: u64, - pub destination: Contract, - pub entrypoint: Entrypoint, - pub value: Vec, - } + pub struct Transaction(ManagerOperationContent); #[uniffi::export] impl Transaction { @@ -148,67 +121,50 @@ pub mod operation { entrypoint: Option>, value: Option>, ) -> Self { - Self { - source: source.clone(), - fee, - counter, - gas_limit, - storage_limit, - amount, - destination: destination.clone(), - entrypoint: entrypoint.map_or_else(Entrypoint::default, |entrypoint| { - entrypoint.as_ref().clone() - }), - // octez-client convert data "Unit" from Michelson to binary - value: value.unwrap_or(vec![0x03, 0x0b]), - } - } - - #[doc = "Forge the operation."] - pub fn forge(&self) -> Result, Error> { - let transaction = OperationContent::Transaction(ManagerOperationContent { - source: self.source.0.clone(), - fee: self.fee.into(), - counter: self.counter.into(), - gas_limit: self.gas_limit.into(), - storage_limit: self.storage_limit.into(), + Self(ManagerOperationContent { + source: source.0.clone(), + fee: fee.into(), + counter: counter.into(), + gas_limit: gas_limit.into(), + storage_limit: storage_limit.into(), operation: TransactionContent { - amount: self.amount.into(), - destination: self.destination.0.clone(), + amount: amount.into(), + destination: destination.0.clone(), parameters: Parameters { - entrypoint: self.entrypoint.0.clone(), - value: self.value.clone(), + entrypoint: entrypoint.map_or_else( + tezos_protocol::entrypoint::Entrypoint::default, + |entrypoint| entrypoint.0.clone(), + ), + // octez-client convert data "Unit" from Michelson to binary + value: value.unwrap_or(vec![0x03, 0x0b]).clone(), } .into(), }, - }); - transaction + }) + } + + #[doc = "Forge the operation."] + pub fn forge(&self) -> Result, Error> { + OperationContent::Transaction(self.0.clone()) .to_bytes() .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) } } #[derive(uniffi::Object, Debug)] - pub struct Origination { - pub source: PublicKeyHash, - pub fee: u64, - pub counter: u64, - pub gas_limit: u64, - pub storage_limit: u64, - pub balance: u64, - pub delegate: Option, - // Its script is always as follows: - // "script": { - // "code": [], - // "storage": { - // "prim": "unit" - // } - // } - } + pub struct Origination(ManagerOperationContent); #[uniffi::export] impl Origination { - #[doc = "Build a origination operation."] + /// Build a origination operation. + /// + /// Its script is always as follows: + /// 'script': { + /// 'code': [], + /// 'storage': { + /// 'prim': 'unit' + /// } + /// } #[uniffi::constructor] pub fn new( source: &PublicKeyHash, @@ -219,28 +175,15 @@ pub mod operation { balance: u64, delegate: Option>, ) -> Self { - Self { - source: source.clone(), - fee, - counter, - gas_limit, - storage_limit, - balance, - delegate: delegate.map(|delegate| delegate.as_ref().clone()), - } - } - - #[doc = "Forge the operation."] - pub fn forge(&self) -> Result, Error> { - let origination = OperationContent::Origination(ManagerOperationContent { - source: self.source.0.clone(), - fee: self.fee.into(), - counter: self.counter.into(), - gas_limit: self.gas_limit.into(), - storage_limit: self.storage_limit.into(), + Self(ManagerOperationContent { + source: source.0.clone(), + fee: fee.into(), + counter: counter.into(), + gas_limit: gas_limit.into(), + storage_limit: storage_limit.into(), operation: OriginationContent { - balance: self.balance.into(), - delegate: self.delegate.clone().map(|delegate| delegate.0), + balance: balance.into(), + delegate: delegate.map(|delegate| delegate.0.clone()), script: Script { // Seq(&[]).encode(), code: vec![0x02, 0x00, 0x00, 0x00, 0x00], @@ -248,22 +191,19 @@ pub mod operation { storage: vec![0x03, 0x6c], }, }, - }); - origination + }) + } + + #[doc = "Forge the operation."] + pub fn forge(&self) -> Result, Error> { + OperationContent::Origination(self.0.clone()) .to_bytes() .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) } } #[derive(uniffi::Object, Debug)] - pub struct Delegation { - pub source: PublicKeyHash, - pub fee: u64, - pub counter: u64, - pub gas_limit: u64, - pub storage_limit: u64, - pub delegate: Option, - } + pub struct Delegation(ManagerOperationContent); #[uniffi::export] impl Delegation { @@ -277,30 +217,22 @@ pub mod operation { storage_limit: u64, delegate: Option>, ) -> Self { - Self { - source: source.clone(), - fee, - counter, - gas_limit, - storage_limit, - delegate: delegate.map(|delegate| delegate.as_ref().clone()), - } + Self(ManagerOperationContent { + source: source.0.clone(), + fee: fee.into(), + counter: counter.into(), + gas_limit: gas_limit.into(), + storage_limit: storage_limit.into(), + operation: DelegationContent { + delegate: delegate.map(|delegate| delegate.0.clone()), + }, + }) } #[doc = "Forge the operation."] pub fn forge(&self) -> Result, Error> { let mut out = Vec::::new(); - let delegation = OperationContent::Delegation(ManagerOperationContent { - source: self.source.0.clone(), - fee: self.fee.into(), - counter: self.counter.into(), - gas_limit: self.gas_limit.into(), - storage_limit: self.storage_limit.into(), - operation: DelegationContent { - delegate: self.delegate.clone().map(|delegate| delegate.0), - }, - }); - delegation + OperationContent::Delegation(self.0.clone()) .bin_write(&mut out) .map_err(|err| Error::Forge(ForgingError::ToBytes(err)))?; Ok(out) -- GitLab From 2d22b09e146d071a38a2a9813dbe2903b2d8753c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Palmer?= Date: Tue, 26 Aug 2025 13:31:25 +0200 Subject: [PATCH 2/2] SDK/bindings: wrap operations in an Operation object --- .../test/kotlin/org/example/TestForging.kt | 8 +- .../rust/python-tests/test_forging.py | 13 +-- contrib/sdk-bindings/rust/src/forge.rs | 100 ++++++------------ .../swift/Tests/TestForging.swift | 8 +- 4 files changed, 43 insertions(+), 86 deletions(-) diff --git a/contrib/sdk-bindings/kotlin/demo/app/src/test/kotlin/org/example/TestForging.kt b/contrib/sdk-bindings/kotlin/demo/app/src/test/kotlin/org/example/TestForging.kt index c6983f6ae715..7cb9f795f60b 100644 --- a/contrib/sdk-bindings/kotlin/demo/app/src/test/kotlin/org/example/TestForging.kt +++ b/contrib/sdk-bindings/kotlin/demo/app/src/test/kotlin/org/example/TestForging.kt @@ -37,7 +37,7 @@ class ForgingTest { @Test fun revealForging() { val publicKey = PublicKey.fromB58check("p2pk66qj2rKg5s6NCHprzPHheLK1dV3ZmGJbfBJEAizxsz2o3qms8vF") val source = PublicKeyHash.fromB58check("tz3NGKzVp8ezNnu5qx8mY3iioSUXKfC1d8Yc") - val reveal = Reveal(source = source, fee = 1000UL, counter = 34UL, gasLimit = 1UL, storageLimit = 16UL, publicKey = publicKey) + val reveal = Operation.reveal(source = source, fee = 1000UL, counter = 34UL, gasLimit = 1UL, storageLimit = 16UL, publicKey = publicKey) val rawReveal = reveal.forge() val expectedBytes = "6b02153c42139fbbe509e9023bb85eac281709766070e80722011002032abac5ad6fc0fbe8e9a0beb3bbbc7481318f8b686b366ceb00ee0b3b51e40c4900".hexToByteArray() assertContentEquals(rawReveal, expectedBytes) @@ -75,7 +75,7 @@ class ForgingTest { val entrypoint = Entrypoint("add_liquidity") // octez-client convert data '(Pair 93735 (Pair 0 "tz3c2XcRc6PhNuFwH1EhYcXtv7gBgdsx8k6J"))' from Michelson to binary val value = "070700a7b80b070700000100000024747a336332586352633650684e75467748314568596358747637674267647378386b364a".hexToByteArray() - val transaction = Transaction(source = source, fee = 30UL, counter = 20UL, gasLimit = 54UL, storageLimit = 45UL, amount = 0UL, destination = destination, entrypoint = entrypoint, value = value) + val transaction = Operation.transaction(source = source, fee = 30UL, counter = 20UL, gasLimit = 54UL, storageLimit = 45UL, amount = 0UL, destination = destination, entrypoint = entrypoint, value = value) val rawTransaction = transaction.forge() val expectedBytes = "6c03db557924e5a295652eff2c1f141d5a5b72b9cc911e14362d0001f4ab1300637efe3616ab27663ee0e4be07d80e4c00ffff0d6164645f6c697175696469747900000033070700a7b80b070700000100000024747a336332586352633650684e75467748314568596358747637674267647378386b364a".hexToByteArray() assertContentEquals(rawTransaction, expectedBytes) @@ -102,7 +102,7 @@ class ForgingTest { @OptIn(kotlin.ExperimentalStdlibApi::class) // `hexToByteArray` is experimental @Test fun OriginationForging() { val source = PublicKeyHash.fromB58check("tz4F2fxv7sKQx9wyoRMteoJwZEZnV9WFU2wL") - val origination = Origination(source = source, fee = 72UL, counter = 41UL, gasLimit = 8017UL, storageLimit = 77UL, balance = 400UL, delegate = source) + val origination = Operation.origination(source = source, fee = 72UL, counter = 41UL, gasLimit = 8017UL, storageLimit = 77UL, balance = 400UL, delegate = source) val rawOrigination = origination.forge() val expectedBytes = "6d03421585a37470f6cbba7aeb70d11bc40b2b23dd684829d13e4d9003ff03421585a37470f6cbba7aeb70d11bc40b2b23dd6800000005020000000000000002036c".hexToByteArray() assertContentEquals(rawOrigination, expectedBytes) @@ -121,7 +121,7 @@ class ForgingTest { @OptIn(kotlin.ExperimentalStdlibApi::class) // `hexToByteArray` is experimental @Test fun removeDelegateForging() { val source = PublicKeyHash.fromB58check("tz4Uzyxg26DJyM4pc1V2pUvLpdsR5jdyzYsZ") - val delegation = Delegation(source = source, fee = 0UL, counter = 54UL, gasLimit = 82UL, storageLimit = 107006UL, delegate = null) + val delegation = Operation.delegation(source = source, fee = 0UL, counter = 54UL, gasLimit = 82UL, storageLimit = 107006UL, delegate = null) val rawDelegation = delegation.forge() val expectedBytes = "6e03db557924e5a295652eff2c1f141d5a5b72b9cc91003652fec30600".hexToByteArray() assertContentEquals(rawDelegation, expectedBytes) diff --git a/contrib/sdk-bindings/rust/python-tests/test_forging.py b/contrib/sdk-bindings/rust/python-tests/test_forging.py index 4226a0a586a5..fde90919a8d0 100644 --- a/contrib/sdk-bindings/rust/python-tests/test_forging.py +++ b/contrib/sdk-bindings/rust/python-tests/test_forging.py @@ -4,10 +4,7 @@ from tezos import ( forge_message, - Reveal, - Transaction, - Origination, - Delegation, + Operation, PublicKey, PublicKeyHash, BlsSignature, @@ -41,7 +38,7 @@ def test_reveal_forging(): public_key = PublicKey.from_b58check("BLpk1nco14hJwGiTzrRp2FBCxZz6ZJ19QRAoh8hyaNMeVARFyuvTGZQgmrPTT5ZkXfS5yKuEupPN") source = PublicKeyHash.from_b58check("tz4HWRiWnefpPHKUmjTfJhHG74q7fEmS5euR") proof = BlsSignature.from_b58check("BLsigAy1Lc4y9kagjUjPFRb5avizhuXSYQyeSsGAsWbiLBwAEHZvQMxrNrH11Bm9SfHpBbCb9RjnucX2FEZbTZ6it7Z7UGFf3mo7uUdi8V2DX5SmaqqwyzyD12E3rUKxgwHkaSyEiMKcTB") - reveal = Reveal( + reveal = Operation.reveal( source=source, fee=3, counter=718, @@ -70,7 +67,7 @@ def test_transaction_forging(): """ source = PublicKeyHash.from_b58check("tz3S6P2LccJNrejt27KvJRb3BcuS5vGghkP8") destination = Contract.from_b58check("tz3hqqamVC1G22LACFoMgcJeFKZgoGMFSfSn") - transaction = Transaction( + transaction = Operation.transaction( source=source, fee=1000000000, counter=123456, @@ -103,7 +100,7 @@ def test_origination_forging(): }' """ source = PublicKeyHash.from_b58check("tz3S6P2LccJNrejt27KvJRb3BcuS5vGghkP8") - origination = Origination( + origination = Operation.origination( source=source, fee=2, counter=603, @@ -131,7 +128,7 @@ def test_delegation_forging(): """ delegate = PublicKeyHash.from_b58check("tz2PbzLDYrPAZS38BteBY7gqtnZfsTqHF2xu") source = PublicKeyHash.from_b58check("tz3hqqamVC1G22LACFoMgcJeFKZgoGMFSfSn") - delegation = Delegation( + delegation = Operation.delegation( source=source, fee=3141, counter=24006, diff --git a/contrib/sdk-bindings/rust/src/forge.rs b/contrib/sdk-bindings/rust/src/forge.rs index f27092619aab..72b3bd37e7e9 100644 --- a/contrib/sdk-bindings/rust/src/forge.rs +++ b/contrib/sdk-bindings/rust/src/forge.rs @@ -66,13 +66,13 @@ pub mod operation { }; #[derive(uniffi::Object, Debug)] - pub struct Reveal(ManagerOperationContent); + pub struct Operation(OperationContent); #[uniffi::export] - impl Reveal { - #[doc = "Build a reveal operation."] + impl Operation { + /// Build a reveal operation. #[uniffi::constructor(default(proof = None))] - pub fn new( + pub fn reveal( source: &PublicKeyHash, fee: u64, counter: u64, @@ -81,7 +81,7 @@ pub mod operation { public_key: &PublicKey, proof: Option>, ) -> Self { - Self(ManagerOperationContent { + Self(OperationContent::Reveal(ManagerOperationContent { source: source.0.clone(), fee: fee.into(), counter: counter.into(), @@ -91,26 +91,13 @@ pub mod operation { pk: public_key.0.clone(), proof: proof.map(|proof| proof.0.clone()), }, - }) + })) } - #[doc = "Forge the operation."] - pub fn forge(&self) -> Result, Error> { - OperationContent::Reveal(self.0.clone()) - .to_bytes() - .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) - } - } - - #[derive(uniffi::Object, Debug)] - pub struct Transaction(ManagerOperationContent); - - #[uniffi::export] - impl Transaction { #[allow(clippy::too_many_arguments)] - #[doc = "Build a transaction operation."] + /// Build a transaction operation. #[uniffi::constructor(default(entrypoint = None, value = None))] - pub fn new( + pub fn transaction( source: &PublicKeyHash, fee: u64, counter: u64, @@ -121,7 +108,7 @@ pub mod operation { entrypoint: Option>, value: Option>, ) -> Self { - Self(ManagerOperationContent { + Self(OperationContent::Transaction(ManagerOperationContent { source: source.0.clone(), fee: fee.into(), counter: counter.into(), @@ -140,22 +127,9 @@ pub mod operation { } .into(), }, - }) - } - - #[doc = "Forge the operation."] - pub fn forge(&self) -> Result, Error> { - OperationContent::Transaction(self.0.clone()) - .to_bytes() - .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) + })) } - } - - #[derive(uniffi::Object, Debug)] - pub struct Origination(ManagerOperationContent); - #[uniffi::export] - impl Origination { /// Build a origination operation. /// /// Its script is always as follows: @@ -166,7 +140,7 @@ pub mod operation { /// } /// } #[uniffi::constructor] - pub fn new( + pub fn origination( source: &PublicKeyHash, fee: u64, counter: u64, @@ -175,7 +149,7 @@ pub mod operation { balance: u64, delegate: Option>, ) -> Self { - Self(ManagerOperationContent { + Self(OperationContent::Origination(ManagerOperationContent { source: source.0.clone(), fee: fee.into(), counter: counter.into(), @@ -191,25 +165,12 @@ pub mod operation { storage: vec![0x03, 0x6c], }, }, - }) - } - - #[doc = "Forge the operation."] - pub fn forge(&self) -> Result, Error> { - OperationContent::Origination(self.0.clone()) - .to_bytes() - .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) + })) } - } - - #[derive(uniffi::Object, Debug)] - pub struct Delegation(ManagerOperationContent); - #[uniffi::export] - impl Delegation { - #[doc = "Build a delegation operation."] + /// Build a delegation operation. #[uniffi::constructor] - pub fn new( + pub fn delegation( source: &PublicKeyHash, fee: u64, counter: u64, @@ -217,7 +178,7 @@ pub mod operation { storage_limit: u64, delegate: Option>, ) -> Self { - Self(ManagerOperationContent { + Self(OperationContent::Delegation(ManagerOperationContent { source: source.0.clone(), fee: fee.into(), counter: counter.into(), @@ -226,16 +187,14 @@ pub mod operation { operation: DelegationContent { delegate: delegate.map(|delegate| delegate.0.clone()), }, - }) + })) } #[doc = "Forge the operation."] pub fn forge(&self) -> Result, Error> { - let mut out = Vec::::new(); - OperationContent::Delegation(self.0.clone()) - .bin_write(&mut out) - .map_err(|err| Error::Forge(ForgingError::ToBytes(err)))?; - Ok(out) + self.0 + .to_bytes() + .map_err(|err| Error::Forge(ForgingError::ToBytes(err))) } } } @@ -304,7 +263,7 @@ mod tests { .unwrap(); let source = PublicKeyHash::from_b58check("tz1QFD9WqLWZmmAuqnnTPPUjfauitYEWdshv").unwrap(); let (fee, counter, gas_limit, storage_limit) = (274, 43947, 169, 0); - let reveal = Reveal::new( + let reveal = Operation::reveal( &source, fee, counter, @@ -345,7 +304,7 @@ mod tests { let source = PublicKeyHash::from_b58check("tz4AebqGUAFk8rTwiS7EpbY8dA3zHmmxiFPT").unwrap(); let proof = BlsSignature::from_b58check("BLsigAw3bp2QZL8YCWptYYYE1zQr4vidqE7WT4jctre5HpAdjVYmXnGeqYfASAzPB2pWaDCdiRBApWY5Y4V7WJapj3GFHBHnTZh6eoxCduu2FfXuNmSKN1NQLiztAt6nBWytrR1xAzZDg9").unwrap(); let (fee, counter, gas_limit, storage_limit) = (469, 3, 2169, 277); - let reveal = Reveal::new( + let reveal = Operation::reveal( &source, fee, counter, @@ -393,7 +352,7 @@ mod tests { let destination = Contract::from_b58check("KT1G4D3W9cf86dzAmZBN9nwUn7sYh4DYMRb4").unwrap(); let entrypoint = Entrypoint::new("foo").unwrap(); let value = hex::decode("07070001010000000161").unwrap(); - let transaction = Transaction::new( + let transaction = Operation::transaction( &source, fee, counter, @@ -439,7 +398,7 @@ mod tests { let (fee, counter, gas_limit, storage_limit, amount) = (332, 24, 4631, 11, 0); let destination = Contract::from_b58check("KT1S5cQmS4wXjG7JubRUCWzH3DaU7S2XfeFT").unwrap(); let entrypoint = Entrypoint::new("stake").unwrap(); - let transaction = Transaction::new( + let transaction = Operation::transaction( &source, fee, counter, @@ -479,7 +438,7 @@ mod tests { let source = PublicKeyHash::from_b58check("tz1SMHZCpzRUoaoz9gA18pNUghpyYY4N6fif").unwrap(); let (fee, counter, gas_limit, storage_limit, amount) = (99, 1401, 1, 0, 200); let destination = Contract::from_b58check("tz4Quq6VcCeJVmCknjzTX5kcrhUzcMruoavF").unwrap(); - let transaction = Transaction::new( + let transaction = Operation::transaction( &source, fee, counter, @@ -523,7 +482,7 @@ mod tests { fn origination_forging() { let source = PublicKeyHash::from_b58check("tz4Quq6VcCeJVmCknjzTX5kcrhUzcMruoavF").unwrap(); let (balance, fee, counter, gas_limit, storage_limit) = (0, 0, 812, 74, 98); - let origination = Origination::new( + let origination = Operation::origination( &source, fee, counter, @@ -566,7 +525,7 @@ mod tests { fn origination_delegated_contract_forging() { let source = PublicKeyHash::from_b58check("tz1SUWNMC3hUdBRzzrbTbiuGPH1KFVifTQw7").unwrap(); let (balance, fee, counter, gas_limit, storage_limit) = (1_000_000, 1722, 461, 67_000, 1); - let origination = Origination::new( + let origination = Operation::origination( &source, fee, counter, @@ -605,7 +564,7 @@ mod tests { PublicKeyHash::from_b58check("tz3NGKzVp8ezNnu5qx8mY3iioSUXKfC1d8Yc").unwrap(); let source = PublicKeyHash::from_b58check("tz1SMHZCpzRUoaoz9gA18pNUghpyYY4N6fif").unwrap(); let (fee, counter, gas_limit, storage_limit) = (13, 66, 271, 128); - let delegation = Delegation::new( + let delegation = Operation::delegation( &source, fee, counter, @@ -639,7 +598,8 @@ mod tests { fn remove_delegate_forging() { let source = PublicKeyHash::from_b58check("tz2GNQB7rXjNXBX6msePzQ2nBWYUUGutYy5p").unwrap(); let (fee, counter, gas_limit, storage_limit) = (609, 7, 12, 11); - let delegation = Delegation::new(&source, fee, counter, gas_limit, storage_limit, None); + let delegation = + Operation::delegation(&source, fee, counter, gas_limit, storage_limit, None); let raw_delegation = delegation.forge().expect(&format!( "Forging operation {:?} should succeed", delegation diff --git a/contrib/sdk-bindings/swift/Tests/TestForging.swift b/contrib/sdk-bindings/swift/Tests/TestForging.swift index d71b8dd53b6e..f0146bcb4f31 100644 --- a/contrib/sdk-bindings/swift/Tests/TestForging.swift +++ b/contrib/sdk-bindings/swift/Tests/TestForging.swift @@ -41,7 +41,7 @@ class TestForging: XCTestCase { func revealForging() { let publicKey = try! PublicKey.fromB58check(data: "sppk7aDfaJGufpeUHY36yeuRu3YLrZqeroqF755SV33mxsZ14psWg9D") let source = try! PublicKeyHash.fromB58check(data: "tz28peirZbqKQR1udNdaL4fWtRGggHygyF9D") - let reveal = Reveal( + let reveal = Operation.reveal( source: source, fee: 47, counter: 5, @@ -82,7 +82,7 @@ class TestForging: XCTestCase { let source = try! PublicKeyHash.fromB58check(data: "tz2GNQB7rXjNXBX6msePzQ2nBWYUUGutYy5p") let destination = try! Contract.fromB58check(data: "tz2GNQB7rXjNXBX6msePzQ2nBWYUUGutYy5p") let entrypoint = try! Entrypoint(name: "finalize_unstake") - let transaction = Transaction( + let transaction = Operation.transaction( source: source, fee: 0, counter: 14, @@ -125,7 +125,7 @@ class TestForging: XCTestCase { func originationForging() { let delegate = try! PublicKeyHash.fromB58check(data: "tz1XFq85mnnXhyhzpNEpxFvrkcuNtFBsSsVu") let source = try! PublicKeyHash.fromB58check(data: "tz2RcdU4n2PvJHUNYkS8FPuvcnFmBqEccxb4") - let origination = Origination( + let origination = Operation.origination( source: source, fee: 1, counter: 30, @@ -161,7 +161,7 @@ class TestForging: XCTestCase { func delegationForging() { let delegate = try! PublicKeyHash.fromB58check(data: "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx") let source = try! PublicKeyHash.fromB58check(data: "tz1QFD9WqLWZmmAuqnnTPPUjfauitYEWdshv") - let delegation = Delegation( + let delegation = Operation.delegation( source: source, fee: 1, counter: 2, -- GitLab