diff --git a/raiden-ts/CHANGELOG.md b/raiden-ts/CHANGELOG.md
index 8a71e78da0..9cb69b08f1 100644
--- a/raiden-ts/CHANGELOG.md
+++ b/raiden-ts/CHANGELOG.md
@@ -4,11 +4,13 @@
### Fixed
### Added
+- [#1910] Add option to `mint` tokens for any address
### Changed
- [#1905] Fail early if not enough tokens to deposit
[#1905]: https://github.com/raiden-network/light-client/issues/1905
+[#1910]: https://github.com/raiden-network/light-client/pull/1910
## [0.10.0] - 2020-07-13
### Fixed
diff --git a/raiden-ts/src/raiden.ts b/raiden-ts/src/raiden.ts
index ca2a98240b..61b555262f 100644
--- a/raiden-ts/src/raiden.ts
+++ b/raiden-ts/src/raiden.ts
@@ -1018,7 +1018,7 @@ export class Raiden {
* Throws an error, if
*
* - Executed on main net
- * - `token` is not a valid address
+ * - `token` or `options.to` is not a valid address
* - Token could not be minted
*
*
@@ -1029,12 +1029,13 @@ export class Raiden {
* Notice the beneficiary here is always the account that sends the transaction, as this is
* expectedly also the account that will pay for e.g. future deposits.
* Set this to true if one wants to force sending the transaction with the subkey
+ * @param options.to - Beneficiary, defaults to mainAddress or address
* @returns transaction
*/
public async mint(
token: string,
amount: BigNumberish,
- { subkey }: { subkey?: boolean } = {},
+ { subkey, to }: { subkey?: boolean; to?: string } = {},
): Promise {
// Check whether address is valid
assert(Address.is(token), [ErrorCodes.DTA_INVALID_ADDRESS, { token }], this.log.info);
@@ -1043,14 +1044,22 @@ export class Raiden {
// Check whether we are on a test network
assert(this.deps.network.chainId !== 1, ErrorCodes.RDN_MINT_MAINNET, this.log.info);
- const { signer } = chooseOnchainAccount(this.deps, subkey ?? this.config.subkey);
+ const { signer, address } = chooseOnchainAccount(this.deps, subkey ?? this.config.subkey);
// Mint token
const customTokenContract = CustomTokenFactory.connect(token, signer);
+ const beneficiary = to ?? address;
+ assert(
+ Address.is(beneficiary),
+ [ErrorCodes.DTA_INVALID_ADDRESS, { beneficiary }],
+ this.log.info,
+ );
+
+ const value = decode(UInt(32), amount, ErrorCodes.DTA_INVALID_AMOUNT);
const receipt = await callAndWaitMined(
customTokenContract,
- 'mint',
- [decode(UInt(32), amount)],
+ 'mintFor',
+ [value, beneficiary],
ErrorCodes.RDN_MINT_FAILED,
{ log: this.log },
);
diff --git a/raiden-ts/tests/e2e/raiden.spec.ts b/raiden-ts/tests/e2e/raiden.spec.ts
index a16cab6c7d..36c86bec20 100644
--- a/raiden-ts/tests/e2e/raiden.spec.ts
+++ b/raiden-ts/tests/e2e/raiden.spec.ts
@@ -1187,7 +1187,9 @@ describe('Raiden', () => {
test('should return transaction if minted successfully', async () => {
expect.assertions(1);
- await expect(raiden.mint(token, 50)).resolves.toMatch(/^0x[0-9a-fA-F]{64}$/);
+ await expect(raiden.mint(token, 50, { to: raiden.address })).resolves.toMatch(
+ /^0x[0-9a-fA-F]{64}$/,
+ );
});
});