Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #80 from monerium/feat/sepolia
Browse files Browse the repository at this point in the history
feat: sepolia
  • Loading branch information
einaralex authored Feb 5, 2024
2 parents bd8a219 + 6de28cd commit 73e059f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion apps/examples/safe-onramp/src/app/on-ramp-kit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ declare global {
}
}

const CHAIN_ID = 5;
const CHAIN_ID = 11155111;

const web3Provider = new ethers.providers.Web3Provider(
window.ethereum,
Expand Down
6 changes: 3 additions & 3 deletions libs/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ yarn add @monerium/sdk

| Environment | Chain | Network |
| ----------- | -------- | ------- |
| sandbox | ethereum | goerli |
| sandbox | ethereum | sepolia |
| | polygon | mumbai |
| | gnosis | chiado |
| production | ethereum | mainnet |
Expand Down Expand Up @@ -222,7 +222,7 @@ await monerium.linkAddress(profileId, {
message: LINK_MESSAGE
signature,
accounts: [
{"currency":"eur","chain":"ethereum","network":"goerli"},
{"currency":"eur","chain":"ethereum","network":"sepolia"},
{"currency":"eur","chain":"gnosis","network":"chiado"}
],
} as LinkAddress);
Expand Down Expand Up @@ -281,7 +281,7 @@ const order = await monerium.placeOrder({
message,
memo: 'Powered by Monerium SDK',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
// supportingDocumentId, see below
});
```
Expand Down
8 changes: 4 additions & 4 deletions libs/sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type Config = {

export type ENV = 'sandbox' | 'production';

export type EthereumTestnet = 'goerli';
export type EthereumTestnet = 'sepolia';
export type GnosisTestnet = 'chiado';
export type PolygonTestnet = 'mumbai';

Expand Down Expand Up @@ -45,9 +45,9 @@ export type NetworkStrict<

/*
* -- isValid:
* const network: Network<'ethereum', 'sandbox'> = 'goerli';
* const network: Network<'ethereum', 'sandbox'> = 'sepolia';
* const network: Network<'ethereum'> = 'mainnet';
* const network: Network<'ethereum'> = 'goerli'
* const network: Network<'ethereum'> = 'sepolia'
* const network: Network = 'chiado'
*
* -- isInValid:
Expand All @@ -63,7 +63,7 @@ export type Network<
: never
: never;

export type ChainId = number | 1 | 5 | 100 | 137 | 10200 | 80001;
export type ChainId = number | 1 | 11155111 | 100 | 137 | 10200 | 80001;

export enum Currency {
eur = 'eur',
Expand Down
6 changes: 3 additions & 3 deletions libs/sdk/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const urlEncoded = (
export const getChain = (chainId: number): Chain => {
switch (chainId) {
case 1:
case 5:
case 11155111:
return 'ethereum';
case 100:
case 10200:
Expand All @@ -110,8 +110,8 @@ export const getNetwork = (chainId: number): Networks => {
case 100:
case 137:
return 'mainnet';
case 5:
return 'goerli';
case 11155111:
return 'sepolia';
case 10200:
return 'chiado';
case 80001:
Expand Down
18 changes: 9 additions & 9 deletions libs/sdk/test/client-apimock.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('MoneriumClient', () => {
signature: OWNER_SIGNATURE,
accounts: [
{
chainId: 5,
chainId: 11155111,
currency: Currency.eur,
},
{
Expand Down Expand Up @@ -57,7 +57,7 @@ describe('MoneriumClient', () => {
{
currency: Currency.eur,
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
},
{
currency: Currency.eur,
Expand Down Expand Up @@ -98,7 +98,7 @@ describe('MoneriumClient', () => {
},
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chainId: 5,
chainId: 11155111,
})
.catch(() => ({}));

Expand Down Expand Up @@ -127,7 +127,7 @@ describe('MoneriumClient', () => {
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
}),
})
);
Expand All @@ -148,7 +148,7 @@ describe('MoneriumClient', () => {
identifier: {
standard: PaymentStandard.chain,
address: '0x1234567890123456789012345678901234567890',
chainId: 5,
chainId: 11155111,
},
details: {
firstName: 'Mockbank',
Expand All @@ -158,7 +158,7 @@ describe('MoneriumClient', () => {
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
} as any /** to bypass type error for chain and network, for backwards compatibility */
)
.catch(() => ({}));
Expand All @@ -180,7 +180,7 @@ describe('MoneriumClient', () => {
standard: PaymentStandard.chain,
address: '0x1234567890123456789012345678901234567890',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
},
details: {
firstName: 'Mockbank',
Expand All @@ -190,7 +190,7 @@ describe('MoneriumClient', () => {
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
}),
})
);
Expand Down Expand Up @@ -222,7 +222,7 @@ describe('MoneriumClient', () => {
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
} as any /** to bypass typeerror for chain and network */
)
)
Expand Down
32 changes: 16 additions & 16 deletions libs/sdk/test/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ describe('MoneriumClient', () => {
redirect_uri: 'http://example.com',
client_id: 'testClientId',
address: '0x',
chainId: 5,
chainId: 11155111,
});
const codeVerifier = window.localStorage.getItem(STORAGE_CODE_VERIFIER);
const challenge = generateCodeChallenge(codeVerifier as string);

expect(authFlowUrl).toBe(
`https://api.monerium.dev/auth?client_id=testClientId&redirect_uri=http%3A%2F%2Fexample.com&code_challenge=${challenge}&code_challenge_method=S256&response_type=code&address=0x&chain=ethereum&network=goerli`
`https://api.monerium.dev/auth?client_id=testClientId&redirect_uri=http%3A%2F%2Fexample.com&code_challenge=${challenge}&code_challenge_method=S256&response_type=code&address=0x&chain=ethereum&network=sepolia`
);
});

Expand All @@ -154,14 +154,14 @@ describe('MoneriumClient', () => {
client_id: 'testClientId',
address: '0x',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
});

const codeVerifier = window.localStorage.getItem(STORAGE_CODE_VERIFIER);
const challenge = generateCodeChallenge(codeVerifier as string);

expect(authFlowUrl).toBe(
`https://api.monerium.dev/auth?client_id=testClientId&redirect_uri=http%3A%2F%2Fexample.com&code_challenge=${challenge}&code_challenge_method=S256&response_type=code&address=0x&chain=ethereum&network=goerli`
`https://api.monerium.dev/auth?client_id=testClientId&redirect_uri=http%3A%2F%2Fexample.com&code_challenge=${challenge}&code_challenge_method=S256&response_type=code&address=0x&chain=ethereum&network=sepolia`
);
});

Expand Down Expand Up @@ -198,7 +198,7 @@ describe('MoneriumClient', () => {
accounts: [
{
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
currency: Currency.eur,
},
{
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('MoneriumClient', () => {
const authContext = await client.getAuthContext();
const profile = await client.getProfile(authContext.profiles[0].id);

expect(profile.accounts[0].id).toBe('ebed25b6-6dcb-11ee-8aa6-5273f65ed05b');
expect(profile.accounts[0].id).toBe('ebedb56e-6dcb-11ee-8aa6-5273f65ed05b');
});

test('get balances', async () => {
Expand All @@ -254,7 +254,7 @@ describe('MoneriumClient', () => {
expect.objectContaining({
// id: '4b208818-44e3-11ed-adac-b2efc0e6677d',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
address: PUBLIC_KEY,
}),
])
Expand Down Expand Up @@ -304,11 +304,11 @@ describe('MoneriumClient', () => {
client_secret: APP_ONE_CREDENTIALS_SECRET,
});

const order = await client.getOrder('2dc957ed-6dcc-11ee-85f9-fae826042a04');
const order = await client.getOrder('18c8a048-c474-11ee-b9e4-76cca206b674');

expect(order.kind).toBe('redeem');
expect(order.amount).toBe('1');
expect(order.memo).toBe('Powered by Monerium');
expect(order.kind).toBe('issue');
expect(order.amount).toBe('3000');
expect(order.memo).toBe("Let's make money smarter!");
});

test('get tokens', async () => {
Expand All @@ -323,11 +323,11 @@ describe('MoneriumClient', () => {

const expected = [
{
address: '0x83B844180f66Bbc3BE2E97C6179035AF91c4Cce8',
address: '0xd58C5Db52B5B3Eb24EE38AF287d2cb0F424172A5',
chain: 'ethereum',
currency: 'eur',
decimals: 18,
network: 'goerli',
network: 'sepolia',
symbol: 'EURe',
ticker: 'EUR',
},
Expand Down Expand Up @@ -438,9 +438,9 @@ describe('MoneriumClient', () => {
},
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chainId: 5,
chainId: 11155111,
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
})
.catch((err) => {
expect(err.message).toBe('Invalid signature');
Expand Down Expand Up @@ -479,7 +479,7 @@ describe('MoneriumClient', () => {
message: placeOrderMessage,
memo: 'Powered by Monerium SDK',
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
} as any /** to bypass typeerror for chain and network */
)
.catch((err) => {
Expand Down
14 changes: 7 additions & 7 deletions libs/sdk/test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { Network, NetworkStrict } from '../src/types';
describe('Network type', () => {
test('valid networks', () => {
// loose networks
const goerli: Network = 'goerli';
const sepolia: Network = 'sepolia';
const chiado: Network = 'chiado';
const mumbai: Network = 'mumbai';
const mainnet: Network = 'mainnet';

// semi-strict networks
const ethOnly: Network<'ethereum'> = 'mainnet';
const ethOnlyTest: Network<'ethereum'> = 'goerli';
const ethOnlyTest: Network<'ethereum'> = 'sepolia';

const gnoOnly: Network<'gnosis'> = 'mainnet';
const gnoOnlyTest: Network<'gnosis'> = 'chiado';
Expand All @@ -24,7 +24,7 @@ describe('Network type', () => {
const gnoMain: Network<'gnosis', 'production'> = 'mainnet';
const polMain: Network<'polygon', 'production'> = 'mainnet';

const ethTest: Network<'ethereum', 'sandbox'> = 'goerli';
const ethTest: Network<'ethereum', 'sandbox'> = 'sepolia';
const gnoTest: Network<'gnosis', 'sandbox'> = 'chiado';
const polTest: Network<'polygon', 'sandbox'> = 'mumbai';

Expand All @@ -37,15 +37,15 @@ describe('Network type', () => {
// @ts-expect-error unit test
const gnoTestErr: Network<'gnosis', 'sandbox'> = 'mumbai';
// @ts-expect-error unit test
const polTestErr: Network<'polygon', 'sandbox'> = 'goerli';
const polTestErr: Network<'polygon', 'sandbox'> = 'sepolia';
// @ts-expect-error unit test
const err1: NetworkStrict<'polygon'> = 'goerli';
const err1: NetworkStrict<'polygon'> = 'sepolia';
// @ts-expect-error unit test
const err2: NetworkStrict<'ethereum'> = 'goerli';
const err2: NetworkStrict<'ethereum'> = 'sepolia';
// @ts-expect-error unit test
const err3: NetworkStrict = 'mainnet';
// @ts-expect-error unit test
const err4: NetworkStrict = 'goerli';
const err4: NetworkStrict = 'sepolia';

// the above invalid networks should fail type checking
// so there's no need for additional assertions here
Expand Down
12 changes: 6 additions & 6 deletions libs/sdk/test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ describe('url params', () => {
currency: Currency.eur,
standard: 'iban' as PaymentStandard,
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
},
{
address: 'testAddress2',
currency: Currency.eur,
standard: 'iban' as PaymentStandard,
chain: 'ethereum',
network: 'goerli',
network: 'sepolia',
},
],
};

const result = getIban(profile, 'testAddress2', 5);
const result = getIban(profile, 'testAddress2', 11155111);

expect(result).toBe('');
});
Expand Down Expand Up @@ -280,10 +280,10 @@ describe('placeOrderMessage', () => {

describe('mapChainAndNetwork', () => {
it('should add network and chain properties and remove chainId if chainId is present', () => {
const body = { chainId: 5 };
const body = { chainId: 11155111 };
const expectedBody = {
network: getNetwork(5),
chain: getChain(5),
network: getNetwork(11155111),
chain: getChain(11155111),
};

expect(mapChainAndNetwork(body)).toEqual(expectedBody);
Expand Down

0 comments on commit 73e059f

Please sign in to comment.