Skip to content

Commit

Permalink
Feat/ithaca
Browse files Browse the repository at this point in the history
  • Loading branch information
godenzim committed Mar 26, 2022
1 parent 13ab6da commit c599eed
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 85 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ dependencies {
implementation project(':capacitor-cordova-android-plugins')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

def saplingVersion = "0.0.6"
def saplingVersion = "0.0.7"
implementation "com.github.airgap-it:airgap-sapling:$saplingVersion"
}

Expand Down
2 changes: 1 addition & 1 deletion ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
repositoryURL = "https://github.com/airgap-it/airgap-sapling.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.0.6;
minimumVersion = 0.0.7;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
24 changes: 11 additions & 13 deletions ios/App/App.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"object": {
"pins": [
{
"package": "AirGapSapling",
"repositoryURL": "https://github.com/airgap-it/airgap-sapling.git",
"state": {
"branch": null,
"revision": "c6606fce5d84cea678414681b13ef5efb3629a7e",
"version": "0.0.6"
}
"pins" : [
{
"identity" : "airgap-sapling",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airgap-it/airgap-sapling.git",
"state" : {
"revision" : "00848f05c305c9997c8f7325527ddc20de7edd2b",
"version" : "0.0.7"
}
]
},
"version": 1
}
],
"version" : 2
}
56 changes: 30 additions & 26 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
}
},
"dependencies": {
"@airgap/angular-core": "0.0.27-beta.4",
"@airgap/angular-ngrx": "0.0.27-beta.4",
"@airgap/angular-core": "0.0.27",
"@airgap/angular-ngrx": "0.0.27",
"@airgap/beacon-sdk": "2.3.8",
"@airgap/coinlib-core": "0.12.10-beta.4",
"@airgap/sapling-wasm": "0.0.6",
"@airgap/coinlib-core": "0.13.0",
"@airgap/sapling-wasm": "0.0.7",
"@angular/animations": "^11.2.9",
"@angular/common": "^11.2.9",
"@angular/core": "^11.2.9",
Expand Down
22 changes: 17 additions & 5 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,20 @@ export class AppComponent implements AfterViewInit {
)
const hangzhounetProtocol: TezosProtocol = new TezosProtocol(new TezosProtocolOptions(hangzhounetNetwork))

const ithacanetNetwork: TezosProtocolNetwork = new TezosProtocolNetwork(
'Ithacanet',
NetworkType.TESTNET,
'https://tezos-ithacanet-node.prod.gke.papers.tech',
new TezblockBlockExplorer('https//ithacanet.tezblock.io'),
new TezosProtocolNetworkExtras(
TezosNetwork.ITHACANET,
'https://tezos-ithacanet-conseil.prod.gke.papers.tech',
TezosNetwork.ITHACANET,
'airgap00391'
)
)
const ithacanetProtocol: TezosProtocol = new TezosProtocol(new TezosProtocolOptions(ithacanetNetwork))

const externalMethodProvider:
| TezosSaplingExternalMethodProvider
| undefined = await this.saplingNativeService.createExternalMethodProvider()
Expand All @@ -237,8 +251,8 @@ export class AppComponent implements AfterViewInit {
)

this.protocolService.init({
extraActiveProtocols: [shieldedTezProtocol, hangzhounetProtocol, shieldedTezProtocolTestnet],
extraPassiveSubProtocols: [[hangzhounetProtocol, new TezosKtProtocol(new TezosProtocolOptions(hangzhounetNetwork))]]
extraActiveProtocols: [ithacanetProtocol, shieldedTezProtocol, hangzhounetProtocol, shieldedTezProtocolTestnet],
extraPassiveSubProtocols: [[hangzhounetProtocol, new TezosKtProtocol(new TezosProtocolOptions(hangzhounetNetwork))], [ithacanetProtocol, new TezosKtProtocol(new TezosProtocolOptions(ithacanetNetwork))]]
})

await Promise.all([this.getGenericSubProtocols(), this.initializeTezosDomains()])
Expand Down Expand Up @@ -324,9 +338,7 @@ export class AppComponent implements AfterViewInit {
private async initializeTezosDomains(): Promise<void> {
const tezosDomainsAddresses: Record<TezosNetwork, string | undefined> = {
[TezosNetwork.MAINNET]: 'KT1GBZmSxmnKJXGMdMLbugPfLyUPmuLSMwKS',
[TezosNetwork.EDONET]: 'KT1JJbWfW8CHUY95hG9iq2CEMma1RiKhMHDR',
[TezosNetwork.FLORENCENET]: 'KT1PfBfkfUuvQRN8zuCAyp5MHjNrQqgevS9p',
[TezosNetwork.GRANADANET]: 'KT1Ch6PstAQG32uNfQJUSL2bf2WvimvY5umk',
[TezosNetwork.ITHACANET]: undefined,
[TezosNetwork.HANGZHOUNET]: 'KT1MgQjmWMBQ4LyuMAqZccTkMSUJbEXeGqii',
}

Expand Down
71 changes: 36 additions & 35 deletions src/app/extensions/delegation/TezosDelegationExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AddressService, AmountConverterPipe } from '@airgap/angular-core'
import { DecimalPipe } from '@angular/common'
import { FormBuilder, FormGroup } from '@angular/forms'
import { TranslateService } from '@ngx-translate/core'
import { DelegationInfo, TezosDelegatorAction, TezosProtocol } from '@airgap/coinlib-core'
import { /*DelegationInfo, */TezosDelegatorAction, TezosProtocol } from '@airgap/coinlib-core'
import { DelegateeDetails, DelegatorAction, DelegatorDetails } from '@airgap/coinlib-core/protocols/ICoinDelegateProtocol'
import { NetworkType } from '@airgap/coinlib-core/utils/ProtocolNetwork'
import BigNumber from 'bignumber.js'
Expand All @@ -28,7 +28,7 @@ export class TezosDelegationExtensions extends ProtocolDelegationExtensions<Tezo
public static async create(
coinlibService: CoinlibService,
decimalPipe: DecimalPipe,
amountConverter: AmountConverterPipe,
_amountConverter: AmountConverterPipe,
shortenStringPipe: ShortenStringPipe,
translateService: TranslateService,
addressService: AddressService,
Expand All @@ -38,7 +38,7 @@ export class TezosDelegationExtensions extends ProtocolDelegationExtensions<Tezo
TezosDelegationExtensions.instance = new TezosDelegationExtensions(
coinlibService,
decimalPipe,
amountConverter,
// amountConverter,
shortenStringPipe,
translateService,
addressService,
Expand Down Expand Up @@ -66,7 +66,7 @@ export class TezosDelegationExtensions extends ProtocolDelegationExtensions<Tezo
private constructor(
private readonly coinlibService: CoinlibService,
private readonly decimalPipe: DecimalPipe,
private readonly amountConverterPipe: AmountConverterPipe,
// private readonly amountConverterPipe: AmountConverterPipe,
private readonly shortenStringPipe: ShortenStringPipe,
private readonly translateService: TranslateService,
private readonly addressService: AddressService,
Expand Down Expand Up @@ -187,10 +187,11 @@ export class TezosDelegationExtensions extends ProtocolDelegationExtensions<Tezo
}
}

public async getRewardDisplayDetails(protocol: TezosProtocol, delegator: string): Promise<UIRewardList | undefined> {
const delegatorExtraInfo = await protocol.getDelegationInfo(delegator)
public async getRewardDisplayDetails(_protocol: TezosProtocol, _delegator: string): Promise<UIRewardList | undefined> {
return undefined
// const delegatorExtraInfo = await protocol.getDelegationInfo(delegator)

return this.createDelegatorDisplayRewards(protocol, delegator, delegatorExtraInfo).catch(() => undefined)
// return this.createDelegatorDisplayRewards(protocol, delegator, delegatorExtraInfo).catch(() => undefined)
}

private createDelegateeDisplayDetails(protocol: TezosProtocol, baker?: TezosBakerDetails): UIWidget[] {
Expand Down Expand Up @@ -252,34 +253,34 @@ export class TezosDelegationExtensions extends ProtocolDelegationExtensions<Tezo
: null
}

private async createDelegatorDisplayRewards(
protocol: TezosProtocol,
address: string,
delegatorExtraInfo: DelegationInfo
): Promise<UIRewardList | undefined> {
if (!delegatorExtraInfo.isDelegated || !delegatorExtraInfo.value) {
return undefined
}
const rewardInfo = await protocol.getDelegationRewards(delegatorExtraInfo.value, address)

return new UIRewardList({
rewards: await Promise.all(
rewardInfo.map(async (info) => {
return {
index: info.cycle,
amount: await this.amountConverterPipe.transform(new BigNumber(info.reward), {
protocol
}),
collected: info.payout < new Date(),
timestamp: info.payout.getTime()
}
})
),
indexColLabel: 'delegation-detail-tezos.rewards.index-col_label',
amountColLabel: 'delegation-detail-tezos.rewards.amount-col_label',
payoutColLabel: 'delegation-detail-tezos.rewards.payout-col_label'
})
}
// private async createDelegatorDisplayRewards(
// protocol: TezosProtocol,
// address: string,
// delegatorExtraInfo: DelegationInfo
// ): Promise<UIRewardList | undefined> {
// if (!delegatorExtraInfo.isDelegated || !delegatorExtraInfo.value) {
// return undefined
// }
// const rewardInfo = await protocol.getDelegationRewards(delegatorExtraInfo.value, address)

// return new UIRewardList({
// rewards: await Promise.all(
// rewardInfo.map(async (info) => {
// return {
// index: info.cycle,
// amount: await this.amountConverterPipe.transform(new BigNumber(info.reward), {
// protocol
// }),
// collected: info.payout < new Date(),
// timestamp: info.payout.getTime()
// }
// })
// ),
// indexColLabel: 'delegation-detail-tezos.rewards.index-col_label',
// amountColLabel: 'delegation-detail-tezos.rewards.amount-col_label',
// payoutColLabel: 'delegation-detail-tezos.rewards.payout-col_label'
// })
// }

private async getKnownBakers(): Promise<TezosBakerCollection> {
if (this.knownBakers === undefined) {
Expand Down

0 comments on commit c599eed

Please sign in to comment.