Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions stellar_contract_bindings/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def to_java_type(td: xdr.SCSpecTypeDef, input_type: bool = False):
return "byte[]"
if t == xdr.SCSpecType.SC_SPEC_TYPE_SYMBOL:
return "String"
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS:
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS or t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
return "Address"
if t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
raise NotImplementedError("SC_SPEC_TYPE_MUXED_ADDRESS is not supported")
Expand Down Expand Up @@ -200,7 +200,7 @@ def to_scval(td: xdr.SCSpecTypeDef, name: str):
return f"Scv.toString({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_SYMBOL:
return f"Scv.toSymbol({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS:
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS or t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
return f"Scv.toAddress({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
raise NotImplementedError("SC_SPEC_TYPE_MUXED_ADDRESS is not supported")
Expand Down Expand Up @@ -257,7 +257,7 @@ def from_scval(td: xdr.SCSpecTypeDef, name: str):
return f"Scv.fromString({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_SYMBOL:
return f"Scv.fromSymbol({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS:
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS or t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
return f"Scv.fromAddress({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
raise NotImplementedError("SC_SPEC_TYPE_MUXED_ADDRESS is not supported")
Expand Down
8 changes: 4 additions & 4 deletions stellar_contract_bindings/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def to_py_type(td: xdr.SCSpecTypeDef, input_type: bool = False):
return "bytes"
if t == xdr.SCSpecType.SC_SPEC_TYPE_SYMBOL:
return "str"
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS:
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS or t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
return "Union[Address, str]" if input_type else "Address"
if t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
raise NotImplementedError("SC_SPEC_TYPE_MUXED_ADDRESS is not supported")
Expand Down Expand Up @@ -125,7 +125,7 @@ def to_scval(td: xdr.SCSpecTypeDef, name: str):
return f"scval.to_string({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_SYMBOL:
return f"scval.to_symbol({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS:
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS or t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
return f"scval.to_address({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
raise NotImplementedError("SC_SPEC_TYPE_MUXED_ADDRESS is not supported")
Expand Down Expand Up @@ -185,7 +185,7 @@ def from_scval(td: xdr.SCSpecTypeDef, name: str):
return f"scval.from_string({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_SYMBOL:
return f"scval.from_symbol({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS:
if t == xdr.SCSpecType.SC_SPEC_TYPE_ADDRESS or t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
return f"scval.from_address({name})"
if t == xdr.SCSpecType.SC_SPEC_TYPE_MUXED_ADDRESS:
raise NotImplementedError("SC_SPEC_TYPE_MUXED_ADDRESS is not supported")
Expand Down Expand Up @@ -686,7 +686,7 @@ def command(contract_id: str, rpc_url: str, output: str, client_type: str):
if __name__ == "__main__":
from stellar_contract_bindings.metadata import parse_contract_metadata

wasm_file = "/Users/overcat/repo/lightsail/stellar-contract-bindings/tests/contracts/target/wasm32-unknown-unknown/release/python.wasm"
wasm_file = "/Users/overcat/repo/lightsail/stellar-contract-bindings/tests/contracts/target/wasm32v1-none/release/python.wasm"
with open(wasm_file, "rb") as f:
wasm = f.read()

Expand Down
50 changes: 49 additions & 1 deletion tests/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,30 @@ def address(
restore=restore,
)

def muxed_address(
self,
address: Union[Address, str],
source: Union[str, MuxedAccount] = NULL_ACCOUNT,
signer: Optional[Keypair] = None,
base_fee: int = 100,
transaction_timeout: int = 300,
submit_timeout: int = 30,
simulate: bool = True,
restore: bool = True,
) -> AssembledTransaction[Address]:
return self.invoke(
"muxed_address",
[scval.to_address(address)],
parse_result_xdr_fn=lambda v: scval.from_address(v),
source=source,
signer=signer,
base_fee=base_fee,
transaction_timeout=transaction_timeout,
submit_timeout=submit_timeout,
simulate=simulate,
restore=restore,
)

def bytes_(
self,
bytes_: bytes,
Expand Down Expand Up @@ -1527,6 +1551,30 @@ async def address(
restore=restore,
)

async def muxed_address(
self,
address: Union[Address, str],
source: Union[str, MuxedAccount] = NULL_ACCOUNT,
signer: Optional[Keypair] = None,
base_fee: int = 100,
transaction_timeout: int = 300,
submit_timeout: int = 30,
simulate: bool = True,
restore: bool = True,
) -> AssembledTransactionAsync[Address]:
return await self.invoke(
"muxed_address",
[scval.to_address(address)],
parse_result_xdr_fn=lambda v: scval.from_address(v),
source=source,
signer=signer,
base_fee=base_fee,
transaction_timeout=transaction_timeout,
submit_timeout=submit_timeout,
simulate=simulate,
restore=restore,
)

async def bytes_(
self,
bytes_: bytes,
Expand Down Expand Up @@ -2034,4 +2082,4 @@ async def duration(
submit_timeout=submit_timeout,
simulate=simulate,
restore=restore,
)
)
6 changes: 5 additions & 1 deletion tests/contracts/contracts/python/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![no_std]
use soroban_sdk::{
contract, contracterror, contractimpl, contracttype, symbol_short, vec, Address, Bytes, BytesN,
Duration, Env, Map, String, Symbol, Timepoint, Val, Vec, I256, U256,
Duration, Env, Map, MuxedAddress, String, Symbol, Timepoint, Val, Vec, I256, U256,
};

#[contract]
Expand Down Expand Up @@ -154,6 +154,10 @@ impl Contract {
address
}

pub fn muxed_address(_env: Env, address: MuxedAddress) -> MuxedAddress {
address
}

pub fn bytes_(_env: Env, bytes_: Bytes) -> Bytes {
bytes_
}
Expand Down
2 changes: 1 addition & 1 deletion tests/contracts/deploy_python_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
print(f"WASM Uploaded, ID: {wasm_id.hex()}")

contract_id = ContractClient.create_contract(wasm_id, kp.public_key, kp, soroban_server,
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE, salt=b'\x00' * 32)
network_passphrase=Network.TESTNET_NETWORK_PASSPHRASE)
print(f"Contract Created, ID: {contract_id}")
Loading
Loading