Skip to content

Commit

Permalink
dev txEmulator - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 committed Oct 7, 2024
1 parent ddceb2f commit a22ebf5
Show file tree
Hide file tree
Showing 28 changed files with 2,860 additions and 2,406 deletions.
4 changes: 4 additions & 0 deletions cell/src/main/java/org/ton/java/cell/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,10 @@ public String toBase64() {
return Utils.bytesToBase64(toBoc(true));
}

public String toBase64UrlSafe() {
return Utils.bytesToBase64SafeUrl(toBoc(true));
}

public String toBase64(boolean withCrc) {
return Utils.bytesToBase64(toBoc(withCrc));
}
Expand Down
100 changes: 59 additions & 41 deletions cell/src/main/java/org/ton/java/tlb/types/MsgAddressIntStd.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package org.ton.java.tlb.types;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import java.math.BigInteger;
import lombok.Builder;
import lombok.Data;
import org.ton.java.address.Address;
import org.ton.java.cell.Cell;
import org.ton.java.cell.CellBuilder;
import org.ton.java.cell.CellSlice;

import java.math.BigInteger;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

/**
*
*
* <pre>
* addr_std$10 anycast:(Maybe Anycast) workchain_id:int8 address:bits256 = MsgAddressInt;
*
Expand All @@ -22,47 +23,64 @@
@Builder
@Data
public class MsgAddressIntStd implements MsgAddressInt {
int magic;
Anycast anycast;
byte workchainId;
BigInteger address;
int magic;
Anycast anycast;
byte workchainId;
BigInteger address;

@Override
public String toString() {
return nonNull(address) ? (workchainId + ":" + address.toString(16)) : null;
}
@Override
public String toString() {
return nonNull(address) ? (workchainId + ":" + address.toString(16)) : null;
}

public Cell toCell() {
CellBuilder result = CellBuilder.beginCell();
result.storeUint(0b10, 2);
if (isNull(anycast)) {
result.storeBit(false);
} else {
result.storeBit(true);
result.storeCell(anycast.toCell());
}
result.storeInt(workchainId, 8);
result.storeUint(address, 256);
return result.endCell();
public Cell toCell() {
CellBuilder result = CellBuilder.beginCell();
result.storeUint(0b10, 2);
if (isNull(anycast)) {
result.storeBit(false);
} else {
result.storeBit(true);
result.storeCell(anycast.toCell());
}
result.storeInt(workchainId, 8);
result.storeUint(address, 256);
return result.endCell();
}

public static MsgAddressIntStd deserialize(CellSlice cs) {
int magic = cs.loadUint(2).intValue();
assert (magic == 0b10) : "MsgAddressIntStd: magic not equal to 0b10, found " + magic;
public static MsgAddressIntStd deserialize(CellSlice cs) {
int magic = cs.loadUint(2).intValue();
assert (magic == 0b10) : "MsgAddressIntStd: magic not equal to 0b10, found " + magic;

Anycast anycast = null;
if (cs.loadBit()) {
anycast = Anycast.deserialize(cs);
}
return MsgAddressIntStd.builder()
.magic(magic)
.anycast(anycast)
.workchainId(cs.loadInt(8).byteValue())
.address(cs.loadUint(256))
.build();
Anycast anycast = null;
if (cs.loadBit()) {
anycast = Anycast.deserialize(cs);
}
return MsgAddressIntStd.builder()
.magic(magic)
.anycast(anycast)
.workchainId(cs.loadInt(8).byteValue())
.address(cs.loadUint(256))
.build();
}

public Address toAddress() {
return Address.of(toString());
}
public Address toAddress() {
return Address.of(toString());
}

public static MsgAddressIntStd of(String address) {
Address addr = new Address(address);
return MsgAddressIntStd.builder()
.workchainId(addr.wc)
.address(addr.toBigInteger())
.anycast(null)
.build();
}

public static MsgAddressIntStd of(Address address) {
return MsgAddressIntStd.builder()
.workchainId(address.wc)
.address(address.toBigInteger())
.anycast(null)
.build();
}
}
Loading

0 comments on commit a22ebf5

Please sign in to comment.