@credenza3/contracts-lib-sui 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,10 +8,11 @@ export declare class CredenzaSuiSigner extends Signer {
8
8
  private credenzaApiSuiUrl;
9
9
  private credenzaAccessToken;
10
10
  private credenzaAccountSuiPublicKey;
11
+ private sponsorAddress;
11
12
  constructor(opts: CredenzaSuiSignerOptions);
12
13
  initialize(): Promise<void>;
13
14
  useSponsoredTransactions(value: boolean): void;
14
- getGasOwner(): string;
15
+ getGasOwner(): Promise<string>;
15
16
  sign(bytes: Uint8Array): ReturnType<Signer['sign']>;
16
17
  signTransaction(bytes: Uint8Array): ReturnType<Signer['signTransaction']>;
17
18
  getKeyScheme(): SignatureScheme;
@@ -1898,8 +1898,21 @@ var CredenzaSuiSigner = class extends Signer {
1898
1898
  useSponsoredTransactions(value) {
1899
1899
  this.isCredenzaSponsoredTransactions = value;
1900
1900
  }
1901
- getGasOwner() {
1902
- return this.isCredenzaSponsoredTransactions ? DEFAULT_CREDENZA_SPONSOR_ADDRESS : this.toSuiAddress();
1901
+ async getGasOwner() {
1902
+ if (this.isCredenzaSponsoredTransactions) {
1903
+ if (!this.sponsorAddress) {
1904
+ try {
1905
+ const result = await fetch(`${this.credenzaApiSuiUrl}/accounts/sponsor-address`);
1906
+ const json = await result.json();
1907
+ this.sponsorAddress = json.address.toLowerCase();
1908
+ } catch {
1909
+ this.sponsorAddress = DEFAULT_CREDENZA_SPONSOR_ADDRESS;
1910
+ }
1911
+ }
1912
+ return this.sponsorAddress;
1913
+ } else {
1914
+ return this.toSuiAddress();
1915
+ }
1903
1916
  }
1904
1917
  async sign(bytes) {
1905
1918
  const result = await fetch(`${this.credenzaApiSuiUrl}/accounts/sign`, {