perun-network / erdstall-ts-sdk

TypeScript client SDK to interact with Erdstall.
Apache License 2.0
5 stars 2 forks source link

Session.deposit not taking PowDepth into account #147

Open DragonDev1906 opened 2 years ago

DragonDev1906 commented 2 years ago

Either I'm using the sdk wrong, or Session.deposit does not take the PowDepth of the operator into account when waiting on the deposit stage. This code works correctly if the operator is configured with PowDepth==0, but not with a PowDepth>0.

See below for the OpClientConfig struct sent by the operator and the javascript I used to wait until the deposit is finished.

// OpClientConfig describes the part of the client's configuration which is sent
// to connecting clients by the operator.
type OpClientConfig struct {
    NetworkID int64          `json:"networkID,string"` // Network-ID
    Contract  common.Address `json:"contract"`
    POWDepth  uint64         `json:"powDepth"`
}
async function deposit(erdSession, token, amount) {
    let { stages } = await erdSession.deposit(new Assets({
        token: token,
        asset: new Amount(amount)
    }))

    for await (const [_name , stage] of stages) {
        console.log("DEPOSIT: Waiting on", _name, "stage")
        const ctx = await stage.wait()
        if (ctx.status !== 0x1) {
            console.log("DEPOSIT: Stage", _name, "failed with status", ctx.status)
        } else {
            console.log("DEPOSIT: Stage", _name, "successfully finished")
        }
    }
}
ndzik commented 1 year ago

Bump @ndzik